List of usage examples for com.vaadin.ui HorizontalLayout addStyleName
@Override public void addStyleName(String style)
From source file:de.symeda.sormas.ui.dashboard.contacts.ContactsDashboardView.java
License:Open Source License
protected HorizontalLayout createEpiCurveAndMapLayout() { HorizontalLayout layout = new HorizontalLayout(); layout.addStyleName(DashboardCssStyles.CURVE_AND_MAP_LAYOUT); layout.setWidth(100, Unit.PERCENTAGE); layout.setMargin(false);/* www .java 2 s. c o m*/ layout.setSpacing(false); // Epi curve layout epiCurveLayout = createEpiCurveLayout(); layout.addComponent(epiCurveLayout); // Map layout mapLayout = createMapLayout(); layout.addComponent(mapLayout); return layout; }
From source file:de.symeda.sormas.ui.dashboard.DashboardFilterLayout.java
License:Open Source License
private void createDateFilters() { HorizontalLayout dateFilterLayout = new HorizontalLayout(); dateFilterLayout.addStyleName(CssStyles.LAYOUT_MINIMAL); dateFilterLayout.setSpacing(true);//ww w. j av a 2 s . c o m addComponent(dateFilterLayout); Date now = new Date(); // Date filters Button todayButton = new Button(I18nProperties.getCaption(Captions.dashboardToday)); initializeDateFilterButton(todayButton); todayButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfDay(now), DateHelper.getEndOfDay(now)); dashboardView.refreshDashboard(); }); Button yesterdayButton = new Button(I18nProperties.getCaption(Captions.dashboardYesterday)); initializeDateFilterButton(yesterdayButton); yesterdayButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfDay(DateHelper.subtractDays(now, 1)), DateHelper.getEndOfDay(DateHelper.subtractDays(now, 1))); dashboardView.refreshDashboard(); }); Button thisWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardThisWeek)); initializeDateFilterButton(thisWeekButton); thisWeekButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfWeek(now), DateHelper.getEndOfWeek(now)); dashboardView.refreshDashboard(); }); CssStyles.style(thisWeekButton, CssStyles.BUTTON_FILTER_DARK); CssStyles.removeStyles(thisWeekButton, CssStyles.BUTTON_FILTER_LIGHT); Button lastWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardLastWeek)); initializeDateFilterButton(lastWeekButton); lastWeekButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfWeek(DateHelper.subtractWeeks(now, 1)), DateHelper.getEndOfWeek(DateHelper.subtractWeeks(now, 1))); dashboardView.refreshDashboard(); }); Button thisYearButton = new Button(I18nProperties.getCaption(Captions.dashboardThisYear)); initializeDateFilterButton(thisYearButton); thisYearButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfYear(now), DateHelper.getEndOfYear(now)); dashboardView.refreshDashboard(); }); Button lastYearButton = new Button(I18nProperties.getCaption(Captions.dashboardLastYear)); initializeDateFilterButton(lastYearButton); lastYearButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfYear(DateHelper.subtractYears(now, 1)), DateHelper.getEndOfYear(DateHelper.subtractYears(now, 1))); dashboardView.refreshDashboard(); }); customButton = new PopupButton(I18nProperties.getCaption(Captions.dashboardCustom)); initializeDateFilterButton(customButton); // Custom filter HorizontalLayout customDateFilterLayout = new HorizontalLayout(); customDateFilterLayout.setSpacing(true); customDateFilterLayout.setMargin(true); // 'Apply custom filter' button Button applyButton = new Button(I18nProperties.getCaption(Captions.dashboardApplyCustomFilter)); CssStyles.style(applyButton, CssStyles.FORCE_CAPTION, ValoTheme.BUTTON_PRIMARY); // Date & Epi Week filter EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = new EpiWeekAndDateFilterComponent<>( applyButton, true, true, I18nProperties.getString(Strings.infoCaseDate)); customDateFilterLayout.addComponent(weekAndDateFilter); dashboardDataProvider .setDateFilterOption((DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue()); dashboardDataProvider.setFromDate( DateHelper.getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue())); dashboardDataProvider .setToDate(DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue())); customDateFilterLayout.addComponent(applyButton); // Apply button listener applyButton.addClickListener(e -> { DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter() .getValue(); Date fromDate = null; Date toDate = null; EpiWeek fromWeek = null; EpiWeek toWeek = null; dashboardDataProvider.setDateFilterOption(dateFilterOption); if (dateFilterOption == DateFilterOption.DATE) { fromDate = weekAndDateFilter.getDateFromFilter().getValue(); dashboardDataProvider.setFromDate(fromDate); toDate = weekAndDateFilter.getDateToFilter().getValue(); dashboardDataProvider.setToDate(toDate); } else { fromWeek = (EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue(); dashboardDataProvider.setFromDate(DateHelper.getEpiWeekStart(fromWeek)); toWeek = (EpiWeek) weekAndDateFilter.getWeekToFilter().getValue(); dashboardDataProvider.setToDate(DateHelper.getEpiWeekEnd(toWeek)); } if ((fromDate != null && toDate != null) || (fromWeek != null && toWeek != null)) { changeDateFilterButtonsStyles(customButton); dashboardView.refreshDashboard(); if (dateFilterOption == DateFilterOption.DATE) { customButton.setCaption(DateHelper.formatLocalShortDate(fromDate) + " - " + DateHelper.formatLocalShortDate(toDate)); } else { customButton.setCaption(fromWeek.toShortString() + " - " + toWeek.toShortString()); } } else { if (dateFilterOption == DateFilterOption.DATE) { new Notification(I18nProperties.getString(Strings.headingMissingDateFilter), I18nProperties.getString(Strings.messageMissingDateFilter), Type.ERROR_MESSAGE, false) .show(Page.getCurrent()); } else { new Notification(I18nProperties.getString(Strings.headingMissingEpiWeekFilter), I18nProperties.getString(Strings.messageMissingEpiWeekFilter), Type.ERROR_MESSAGE, false).show(Page.getCurrent()); } } }); customButton.setContent(customDateFilterLayout); dateFilterLayout.addComponents(todayButton, yesterdayButton, thisWeekButton, lastWeekButton, thisYearButton, lastYearButton, customButton); infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML); infoLabel.setSizeUndefined(); CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY); addComponent(infoLabel); setComponentAlignment(infoLabel, Alignment.TOP_RIGHT); }
From source file:de.symeda.sormas.ui.events.EventParticipantsView.java
License:Open Source License
public HorizontalLayout createTopBar() { HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setSpacing(true);// www .j ava2 s . co m topLayout.setWidth("100%"); Label header = new Label(I18nProperties.getPrefixCaption(EventDto.I18N_PREFIX, EventDto.EVENT_PERSONS)); header.setSizeUndefined(); CssStyles.style(header, CssStyles.H2, CssStyles.VSPACE_NONE); topLayout.addComponent(header); // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { topLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getEventParticipantController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); topLayout.addComponent(bulkOperationsDropdown); topLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT); topLayout.setExpandRatio(bulkOperationsDropdown, 1); } if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_CREATE)) { addButton = new Button(I18nProperties.getCaption(Captions.eventParticipantAddPerson)); addButton.addStyleName(ValoTheme.BUTTON_PRIMARY); addButton.setIcon(VaadinIcons.PLUS_CIRCLE); addButton.addClickListener(e -> { ControllerProvider.getEventParticipantController().createEventParticipant(this.getEventRef(), r -> grid.reload()); }); topLayout.addComponent(addButton); topLayout.setComponentAlignment(addButton, Alignment.MIDDLE_RIGHT); } topLayout.addStyleName(CssStyles.VSPACE_3); return topLayout; }
From source file:de.symeda.sormas.ui.events.EventsView.java
License:Open Source License
public HorizontalLayout createStatusFilterBar() { HorizontalLayout statusFilterLayout = new HorizontalLayout(); statusFilterLayout.setSpacing(true); statusFilterLayout.setMargin(false); statusFilterLayout.setWidth(100, Unit.PERCENTAGE); statusFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> { criteria.eventStatus(null);/*from w w w . j a va 2 s . co m*/ navigateTo(criteria); }); CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); statusAll.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusAll); statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all)); activeStatusButton = statusAll; for (EventStatus status : EventStatus.values()) { Button statusButton = new Button(status.toString(), e -> { criteria.eventStatus(status); navigateTo(criteria); }); statusButton.setData(status); CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT); statusButton.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusButton); statusButtons.put(statusButton, status.toString()); } HorizontalLayout actionButtonsLayout = new HorizontalLayout(); actionButtonsLayout.setSpacing(true); { // Show archived/active cases button if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_VIEW_ARCHIVED)) { switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.eventShowArchived)); switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK); switchArchivedActiveButton.addClickListener(e -> { criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE); navigateTo(criteria); }); actionButtonsLayout.addComponent(switchArchivedActiveButton); } // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command changeCommand = selectedItem -> { ControllerProvider.getEventController() .showBulkEventDataEditComponent(grid.asMultiSelect().getSelectedItems()); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, changeCommand); Command deleteCommand = selectedItem -> { ControllerProvider.getEventController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); Command archiveCommand = selectedItem -> { ControllerProvider.getEventController() .archiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; archiveItem = bulkOperationsItem.addItem( I18nProperties.getCaption(I18nProperties.getCaption(Captions.actionArchive)), VaadinIcons.ARCHIVE, archiveCommand); Command dearchiveCommand = selectedItem -> { ControllerProvider.getEventController() .dearchiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; dearchiveItem = bulkOperationsItem.addItem( I18nProperties.getCaption(I18nProperties.getCaption(Captions.actionDearchive)), VaadinIcons.ARCHIVE, dearchiveCommand); dearchiveItem.setVisible(false); actionButtonsLayout.addComponent(bulkOperationsDropdown); } } statusFilterLayout.addComponent(actionButtonsLayout); statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT); statusFilterLayout.setExpandRatio(actionButtonsLayout, 1); return statusFilterLayout; }
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);// w w w . jav a 2 s . co 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.reports.ReportsView.java
License:Open Source License
public HorizontalLayout createFilterBar() { HorizontalLayout filterLayout = new HorizontalLayout(); filterLayout.setMargin(false);/*from w ww . jav a 2 s . c o m*/ filterLayout.setSpacing(true); filterLayout.addStyleName(CssStyles.VSPACE_3); filterLayout.setWidth(100, Unit.PERCENTAGE); EpiWeek prevEpiWeek = DateHelper.getPreviousEpiWeek(new Date()); int year = prevEpiWeek.getYear(); int week = prevEpiWeek.getWeek(); yearFilter = new ComboBox(); yearFilter.setWidth(200, Unit.PIXELS); yearFilter.addItems(DateHelper.getYearsToNow()); yearFilter.select(year); yearFilter.setCaption(I18nProperties.getString(Strings.year)); yearFilter.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING); yearFilter.addValueChangeListener(e -> { updateEpiWeeks((int) e.getProperty().getValue(), (int) epiWeekFilter.getValue()); reloadGrid(); }); filterLayout.addComponent(yearFilter); epiWeekFilter = new ComboBox(); epiWeekFilter.setWidth(200, Unit.PIXELS); updateEpiWeeks(year, week); epiWeekFilter.setCaption(I18nProperties.getString(Strings.epiWeek)); epiWeekFilter.addValueChangeListener(e -> { reloadGrid(); }); filterLayout.addComponent(epiWeekFilter); Button lastWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardLastWeek)); lastWeekButton.addStyleName(CssStyles.FORCE_CAPTION); lastWeekButton.addClickListener(e -> { EpiWeek epiWeek = DateHelper.getPreviousEpiWeek(new Date()); yearFilter.select(epiWeek.getYear()); epiWeekFilter.select(epiWeek.getWeek()); }); filterLayout.addComponent(lastWeekButton); Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML); infoLabel.setDescription(I18nProperties.getString(Strings.infoWeeklyReportsView)); infoLabel.setSizeUndefined(); CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY); filterLayout.addComponent(infoLabel); filterLayout.setComponentAlignment(infoLabel, Alignment.MIDDLE_RIGHT); filterLayout.setExpandRatio(infoLabel, 1); return filterLayout; }
From source file:de.symeda.sormas.ui.samples.SampleGridComponent.java
License:Open Source License
public HorizontalLayout createShipmentFilterBar() { HorizontalLayout shipmentFilterLayout = new HorizontalLayout(); shipmentFilterLayout.setMargin(false); shipmentFilterLayout.setSpacing(true); shipmentFilterLayout.setWidth(100, Unit.PERCENTAGE); shipmentFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); HorizontalLayout buttonFilterLayout = new HorizontalLayout(); buttonFilterLayout.setSpacing(true); {//from ww w.j a v a 2 s . c o m Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> processStatusChange(null)); CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); statusAll.setCaptionAsHtml(true); buttonFilterLayout.addComponent(statusAll); statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all)); activeStatusButton = statusAll; Button notShippedButton = new Button(I18nProperties.getCaption(Captions.sampleNotShipped), e -> processStatusChange(NOT_SHIPPED)); initializeStatusButton(notShippedButton, buttonFilterLayout, NOT_SHIPPED, I18nProperties.getCaption(Captions.sampleNotShipped)); Button shippedButton = new Button(I18nProperties.getCaption(Captions.sampleShipped), e -> processStatusChange(SHIPPED)); initializeStatusButton(shippedButton, buttonFilterLayout, SHIPPED, I18nProperties.getCaption(Captions.sampleShipped)); Button receivedButton = new Button(I18nProperties.getCaption(Captions.sampleReceived), e -> processStatusChange(RECEIVED)); initializeStatusButton(receivedButton, buttonFilterLayout, RECEIVED, I18nProperties.getCaption(Captions.sampleReceived)); Button referredButton = new Button(I18nProperties.getCaption(Captions.sampleReferred), e -> processStatusChange(REFERRED)); initializeStatusButton(referredButton, buttonFilterLayout, REFERRED, I18nProperties.getCaption(Captions.sampleReferred)); } shipmentFilterLayout.addComponent(buttonFilterLayout); HorizontalLayout actionButtonsLayout = new HorizontalLayout(); actionButtonsLayout.setSpacing(true); { // Show archived/active cases button if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW_ARCHIVED)) { switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.sampleShowArchived)); switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK); switchArchivedActiveButton.addClickListener(e -> { criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE); samplesView.navigateTo(criteria); }); actionButtonsLayout.addComponent(switchArchivedActiveButton); } // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { shipmentFilterLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getSampleController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); actionButtonsLayout.addComponent(bulkOperationsDropdown); } } shipmentFilterLayout.addComponent(actionButtonsLayout); shipmentFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT); shipmentFilterLayout.setExpandRatio(actionButtonsLayout, 1); return shipmentFilterLayout; }
From source file:de.symeda.sormas.ui.task.TaskGridComponent.java
License:Open Source License
public HorizontalLayout createAssigneeFilterBar() { HorizontalLayout assigneeFilterLayout = new HorizontalLayout(); assigneeFilterLayout.setMargin(false); assigneeFilterLayout.setSpacing(true); assigneeFilterLayout.setWidth(100, Unit.PERCENTAGE); assigneeFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); HorizontalLayout buttonFilterLayout = new HorizontalLayout(); buttonFilterLayout.setSpacing(true); {//from w w w. j av a 2 s .co m Button allTasks = new Button(I18nProperties.getCaption(Captions.all), e -> processAssigneeFilterChange(null)); CssStyles.style(allTasks, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); allTasks.setCaptionAsHtml(true); buttonFilterLayout.addComponent(allTasks); statusButtons.put(allTasks, I18nProperties.getCaption(Captions.all)); Button officerTasks = new Button(I18nProperties.getCaption(Captions.taskOfficerTasks), e -> processAssigneeFilterChange(OFFICER_TASKS)); initializeStatusButton(officerTasks, buttonFilterLayout, OFFICER_TASKS, I18nProperties.getCaption(Captions.taskOfficerTasks)); Button myTasks = new Button(I18nProperties.getCaption(Captions.taskMyTasks), e -> processAssigneeFilterChange(MY_TASKS)); initializeStatusButton(myTasks, buttonFilterLayout, MY_TASKS, I18nProperties.getCaption(Captions.taskMyTasks)); // Default filter for lab users (that don't have any other role) is "My tasks" if ((UserProvider.getCurrent().hasUserRole(UserRole.LAB_USER) || UserProvider.getCurrent().hasUserRole(UserRole.EXTERNAL_LAB_USER)) && UserProvider.getCurrent().getUserRoles().size() == 1) { activeStatusButton = myTasks; } else { activeStatusButton = allTasks; } } assigneeFilterLayout.addComponent(buttonFilterLayout); HorizontalLayout actionButtonsLayout = new HorizontalLayout(); actionButtonsLayout.setSpacing(true); { // Show archived/active cases button if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_VIEW_ARCHIVED)) { switchArchivedActiveButton = new Button( I18nProperties.getCaption(I18nProperties.getCaption(Captions.taskShowArchived))); switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK); switchArchivedActiveButton.addClickListener(e -> { criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE); tasksView.navigateTo(criteria); }); actionButtonsLayout.addComponent(switchArchivedActiveButton); } // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { assigneeFilterLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getTaskController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); actionButtonsLayout.addComponent(bulkOperationsDropdown); } } assigneeFilterLayout.addComponent(actionButtonsLayout); assigneeFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT); assigneeFilterLayout.setExpandRatio(actionButtonsLayout, 1); return assigneeFilterLayout; }
From source file:de.symeda.sormas.ui.user.UsersView.java
License:Open Source License
public HorizontalLayout createFilterBar() { HorizontalLayout filterLayout = new HorizontalLayout(); filterLayout.setMargin(false);/* w w w . j a v a2s . co m*/ filterLayout.setSpacing(true); filterLayout.setSizeUndefined(); filterLayout.addStyleName(CssStyles.VSPACE_3); activeFilter = new ComboBox(); activeFilter.setWidth(200, Unit.PIXELS); activeFilter.setInputPrompt(I18nProperties.getPrefixCaption(UserDto.I18N_PREFIX, UserDto.ACTIVE)); activeFilter.addItems(ACTIVE_FILTER, INACTIVE_FILTER); activeFilter.addValueChangeListener(e -> { criteria.active(ACTIVE_FILTER.equals(e.getProperty().getValue()) ? Boolean.TRUE : INACTIVE_FILTER.equals(e.getProperty().getValue()) ? Boolean.FALSE : null); navigateTo(criteria); }); filterLayout.addComponent(activeFilter); userRolesFilter = new ComboBox(); userRolesFilter.setWidth(200, Unit.PIXELS); userRolesFilter.setInputPrompt(I18nProperties.getPrefixCaption(UserDto.I18N_PREFIX, UserDto.USER_ROLES)); userRolesFilter.addItems(UserRole.getAssignableRoles(UserProvider.getCurrent().getUserRoles())); userRolesFilter.addValueChangeListener(e -> { criteria.userRole((UserRole) e.getProperty().getValue()); navigateTo(criteria); }); filterLayout.addComponent(userRolesFilter); searchField = new TextField(); searchField.setWidth(200, Unit.PIXELS); searchField.setNullRepresentation(""); searchField.setInputPrompt(I18nProperties.getString(Strings.promptUserSearch)); searchField.setImmediate(true); searchField.addTextChangeListener(e -> { criteria.freeText(e.getText()); grid.reload(); }); filterLayout.addComponent(searchField); return filterLayout; }
From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java
public Component createClippingRow(Article a) { Image imageNewsImage = new Image(); String url = a.getUrlToImage(); if (url == null || url.isEmpty()) { url = a.getSourceAsSource().getLogo().toExternalForm(); }//ww w .ja v a 2s. c om imageNewsImage.setSource(new ExternalResource(url)); imageNewsImage.addStyleName("articleimage"); VerticalLayout layoutNewsImage = new VerticalLayout(imageNewsImage); layoutNewsImage.setMargin(false); layoutNewsImage.setSpacing(false); layoutNewsImage.setWidth("200px"); layoutNewsImage.setHeight("150px"); layoutNewsImage.setComponentAlignment(imageNewsImage, Alignment.MIDDLE_CENTER); Label labelHeadLine = new Label(a.getTitle(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H2); labelHeadLine.addStyleName(ValoTheme.LABEL_NO_MARGIN); labelHeadLine.setWidth("100%"); Label labelDescription = new Label(a.getDescription(), ContentMode.HTML); labelDescription.setWidth("100%"); Image imageSource = new Image(); Source s = a.getSourceAsSource(); URL logo; if (s != null) { logo = s.getLogo(); } else { Log.error("Source is null: " + a.getSource()); return new Label("INTERNAL ERROR"); } if (logo != null) { imageSource.setSource(new ExternalResource(logo)); } else { Log.error("Sourcelogo is null: " + s.getName()); } imageSource.setHeight("30px"); Label labelSource = new Label(a.getSourceAsSource().getName()); labelSource.addStyleName(ValoTheme.LABEL_SMALL); LocalDateTime time = a.getPublishedAtAsLocalDateTime(); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); formatter.withZone(ZoneId.of("Europe/Berlin")); Label labelDate = new Label(time.format(formatter)); labelDate.addStyleName(ValoTheme.LABEL_SMALL); Label labelAuthor = new Label(); labelAuthor.addStyleName(ValoTheme.LABEL_SMALL); labelAuthor.setWidth("100%"); if (a.getAuthor() != null && !a.getAuthor().isEmpty()) { labelAuthor.setValue(a.getAuthor()); } Button openWebsite = new Button(VaadinIcons.EXTERNAL_LINK); openWebsite.addClickListener(e -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false)); HorizontalLayout layoutArticleOptions = new HorizontalLayout(); layoutArticleOptions.setWidth("100%"); layoutArticleOptions.addComponents(imageSource, labelSource, labelDate, labelAuthor, openWebsite); layoutArticleOptions.setComponentAlignment(imageSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelDate, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelAuthor, Alignment.MIDDLE_LEFT); layoutArticleOptions.setComponentAlignment(openWebsite, Alignment.MIDDLE_CENTER); layoutArticleOptions.setExpandRatio(labelAuthor, 5); VerticalLayout layoutNewsText = new VerticalLayout(labelHeadLine, labelDescription, layoutArticleOptions); layoutNewsText.setMargin(false); layoutNewsText.setWidth("100%"); HorizontalLayout layoutClipping = new HorizontalLayout(); layoutClipping.setWidth("100%"); layoutClipping.setMargin(true); layoutClipping.addComponents(layoutNewsImage, layoutNewsText); layoutClipping.setComponentAlignment(layoutNewsImage, Alignment.MIDDLE_CENTER); layoutClipping.setExpandRatio(layoutNewsText, 5); layoutClipping.addStyleName(ValoTheme.LAYOUT_CARD); layoutClipping.addStyleName("tags"); return layoutClipping; }