List of usage examples for com.vaadin.ui MenuBar MenuBar
public MenuBar()
From source file:de.symeda.sormas.ui.contact.ContactVisitsView.java
License:Open Source License
public HorizontalLayout createTopBar() { HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setSpacing(true);// w ww . j a va 2s . co m topLayout.setWidth(100, Unit.PERCENTAGE); // statusButtons = new HashMap<>(); // // Button contactButton = new Button(I18nProperties.getCaption(Captions.contactRelated), e -> { // grid.reload(getContactRef()); // processStatusChangeVisuals(e.getButton()); // }); // CssStyles.style(contactButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); // contactButton.setCaptionAsHtml(true); // topLayout.addComponent(contactButton); // statusButtons.put(contactButton, I18nProperties.getCaption(Captions.contactRelated)); // // Button personButton = new Button(I18nProperties.getCaption(Captions.contactPersonVisits), e -> { // ContactDto contact = FacadeProvider.getContactFacade().getContactByUuid(getContactRef().getUuid()); // grid.reload(contact.getPerson()); // processStatusChangeVisuals(e.getButton()); // }); // CssStyles.style(personButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT); // personButton.setCaptionAsHtml(true); // topLayout.addComponent(personButton); // statusButtons.put(personButton, I18nProperties.getCaption(Captions.contactPersonVisits)); // topLayout.setExpandRatio(topLayout.getComponent(topLayout.getComponentCount()-1), 1); // 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.getVisitController() .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.VISIT_CREATE)) { newButton = new Button(I18nProperties.getCaption(Captions.visitNewVisit)); newButton.addStyleName(ValoTheme.BUTTON_PRIMARY); newButton.setIcon(VaadinIcons.PLUS_CIRCLE); newButton.addClickListener(e -> { ControllerProvider.getVisitController().createVisit(this.getContactRef(), r -> grid.reload()); }); topLayout.addComponent(newButton); topLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT); } topLayout.addStyleName(CssStyles.VSPACE_3); // activeStatusButton = contactButton; return topLayout; }
From source file:de.symeda.sormas.ui.events.EventParticipantsView.java
License:Open Source License
public HorizontalLayout createTopBar() { HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setSpacing(true);/* ww w . j a va 2 s. c o 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 ww . 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);/*from ww w.j a v a2 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.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); {/*www. ja v a 2s. 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.statistics.StatisticsFilterComponent.java
License:Open Source License
private HorizontalLayout createFilterAttributeElement() { HorizontalLayout filterAttributeLayout = new HorizontalLayout(); filterAttributeLayout.setSpacing(true); filterAttributeLayout.setWidth(100, Unit.PERCENTAGE); MenuBar filterAttributeDropdown = new MenuBar(); filterAttributeDropdown.setCaption(I18nProperties.getCaption(Captions.statisticsAttribute)); MenuItem filterAttributeItem = filterAttributeDropdown .addItem(I18nProperties.getCaption(Captions.statisticsAttributeSelect), null); MenuBar filterSubAttributeDropdown = new MenuBar(); filterSubAttributeDropdown.setCaption(I18nProperties.getCaption(Captions.statisticsAttributeSpecification)); MenuItem filterSubAttributeItem = filterSubAttributeDropdown.addItem(SPECIFY_YOUR_SELECTION, null); // Add attribute groups for (StatisticsCaseAttributeGroup attributeGroup : StatisticsCaseAttributeGroup.values()) { MenuItem attributeGroupItem = filterAttributeItem.addItem(attributeGroup.toString(), null); attributeGroupItem.setEnabled(false); // Add attributes belonging to the current group for (StatisticsCaseAttribute attribute : attributeGroup.getAttributes()) { Command attributeCommand = selectedItem -> { selectedAttribute = attribute; selectedSubAttribute = null; filterAttributeItem.setText(attribute.toString()); // Add style to keep chosen item selected and remove it from all other items for (MenuItem menuItem : filterAttributeItem.getChildren()) { menuItem.setStyleName(null); }// www . ja v a 2s.c om selectedItem.setStyleName("selected-filter"); // Reset the sub attribute dropdown filterSubAttributeItem.removeChildren(); filterSubAttributeItem.setText(SPECIFY_YOUR_SELECTION); if (attribute.getSubAttributes().length > 0) { for (StatisticsCaseSubAttribute subAttribute : attribute.getSubAttributes()) { if (subAttribute.isUsedForFilters()) { Command subAttributeCommand = selectedSubItem -> { selectedSubAttribute = subAttribute; filterSubAttributeItem.setText(subAttribute.toString()); // Add style to keep chosen item selected and remove it from all other items for (MenuItem menuItem : filterSubAttributeItem.getChildren()) { menuItem.setStyleName(null); } selectedSubItem.setStyleName("selected-filter"); updateFilterElement(); }; filterSubAttributeItem.addItem(subAttribute.toString(), subAttributeCommand); } } // Only add the sub attribute dropdown if there are any sub attributes that are relevant for the filters section if (filterSubAttributeItem.getChildren() != null && filterSubAttributeItem.getChildren().size() > 0) { filterAttributeLayout.addComponent(filterSubAttributeDropdown); filterAttributeLayout.setExpandRatio(filterSubAttributeDropdown, 1); } else { filterAttributeLayout.removeComponent(filterSubAttributeDropdown); } } else { filterAttributeLayout.removeComponent(filterSubAttributeDropdown); } updateFilterElement(); }; filterAttributeItem.addItem(attribute.toString(), attributeCommand); } } filterAttributeLayout.addComponent(filterAttributeDropdown); filterAttributeLayout.setExpandRatio(filterAttributeDropdown, 0); return filterAttributeLayout; }
From source file:de.symeda.sormas.ui.statistics.StatisticsVisualizationElement.java
License:Open Source License
private void createAndAddComponents() { displayedAttributeDropdown = new MenuBar(); displayedAttributeDropdown.setCaption(type.toString(visualizationType)); displayedAttributeItem = displayedAttributeDropdown.addItem(type.getEmptySelectionString(visualizationType), null);/*from www .j a va 2 s . c o m*/ displayedSubAttributeDropdown = new MenuBar(); CssStyles.style(displayedSubAttributeDropdown, CssStyles.FORCE_CAPTION); displayedSubAttributeItem = displayedSubAttributeDropdown .addItem(I18nProperties.getCaption(Captions.statisticsSpecifySelection), null); // Empty selections Command emptyItemCommand = selectedItem -> { attribute = null; subAttribute = null; resetSubAttributeDropdown(); displayedAttributeItem.setText(type.getEmptySelectionString(visualizationType)); removeSelections(displayedAttributeItem); }; emptySelectionItem = displayedAttributeItem.addItem(type.getEmptySelectionString(visualizationType), emptyItemCommand); // Add attribute groups for (StatisticsCaseAttributeGroup attributeGroup : StatisticsCaseAttributeGroup.values()) { MenuItem attributeGroupItem = displayedAttributeItem.addItem(attributeGroup.toString(), null); attributeGroupItem.setEnabled(false); // Add attributes belonging to the current group for (StatisticsCaseAttribute attribute : attributeGroup.getAttributes()) { Command attributeCommand = selectedItem -> { resetSubAttributeDropdown(); this.attribute = attribute; this.subAttribute = null; displayedAttributeItem.setText(attribute.toString()); removeSelections(displayedAttributeItem); selectedItem.setStyleName("selected-filter"); // Build sub attribute dropdown if (attribute.getSubAttributes().length > 0) { for (StatisticsCaseSubAttribute subAttribute : attribute.getSubAttributes()) { if (subAttribute.isUsedForGrouping()) { Command subAttributeCommand = selectedSubItem -> { this.subAttribute = subAttribute; displayedSubAttributeItem.setText(subAttribute.toString()); removeSelections(displayedSubAttributeItem); selectedSubItem.setStyleName("selected-filter"); }; displayedSubAttributeItem.addItem(subAttribute.toString(), subAttributeCommand); } } addComponent(displayedSubAttributeDropdown); } }; displayedAttributeItem.addItem(attribute.toString(), attributeCommand); } } addComponent(displayedAttributeDropdown); }
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); {// w ww. j a va2 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.therapy.TherapyView.java
License:Open Source License
private VerticalLayout createPrescriptionsHeader() { VerticalLayout prescriptionsHeader = new VerticalLayout(); prescriptionsHeader.setMargin(false); prescriptionsHeader.setSpacing(false); prescriptionsHeader.setWidth(100, Unit.PERCENTAGE); HorizontalLayout headlineRow = new HorizontalLayout(); headlineRow.setMargin(false);// w w w .j av a 2 s . c o m headlineRow.setSpacing(true); headlineRow.setWidth(100, Unit.PERCENTAGE); { Label prescriptionsLabel = new Label(I18nProperties.getString(Strings.entityPrescriptions)); CssStyles.style(prescriptionsLabel, CssStyles.H3); headlineRow.addComponent(prescriptionsLabel); headlineRow.setExpandRatio(prescriptionsLabel, 1); // Bulk operations if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getTherapyController() .deleteAllSelectedPrescriptions(prescriptionGrid.getSelectedRows(), new Runnable() { public void run() { reloadPrescriptionGrid(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); headlineRow.addComponent(bulkOperationsDropdown); headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT); } Button newPrescriptionButton = new Button( I18nProperties.getCaption(Captions.prescriptionNewPrescription)); CssStyles.style(newPrescriptionButton, ValoTheme.BUTTON_PRIMARY); newPrescriptionButton.addClickListener(e -> { ControllerProvider.getTherapyController().openPrescriptionCreateForm( prescriptionCriteria.getTherapy(), this::reloadPrescriptionGrid); }); headlineRow.addComponent(newPrescriptionButton); headlineRow.setComponentAlignment(newPrescriptionButton, Alignment.MIDDLE_RIGHT); } prescriptionsHeader.addComponent(headlineRow); HorizontalLayout filterRow = new HorizontalLayout(); filterRow.setMargin(false); filterRow.setSpacing(true); { prescriptionTypeFilter = new ComboBox(); prescriptionTypeFilter.setWidth(140, Unit.PIXELS); prescriptionTypeFilter.setInputPrompt(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX, PrescriptionDto.PRESCRIPTION_TYPE)); prescriptionTypeFilter.addItems((Object[]) TreatmentType.values()); prescriptionTypeFilter.addValueChangeListener(e -> { prescriptionCriteria.prescriptionType(((TreatmentType) e.getProperty().getValue())); navigateTo(prescriptionCriteria); }); filterRow.addComponent(prescriptionTypeFilter); prescriptionTextFilter = new TextField(); prescriptionTextFilter.setWidth(300, Unit.PIXELS); prescriptionTextFilter.setNullRepresentation(""); prescriptionTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptPrescriptionTextFilter)); prescriptionTextFilter.addTextChangeListener(e -> { prescriptionCriteria.textFilter(e.getText()); reloadPrescriptionGrid(); }); filterRow.addComponent(prescriptionTextFilter); } prescriptionsHeader.addComponent(filterRow); return prescriptionsHeader; }
From source file:de.symeda.sormas.ui.therapy.TherapyView.java
License:Open Source License
private VerticalLayout createTreatmentsHeader() { VerticalLayout treatmentsHeader = new VerticalLayout(); treatmentsHeader.setMargin(false);/*from w ww . j a v a 2 s . co m*/ treatmentsHeader.setSpacing(false); treatmentsHeader.setWidth(100, Unit.PERCENTAGE); HorizontalLayout headlineRow = new HorizontalLayout(); headlineRow.setMargin(false); headlineRow.setSpacing(true); headlineRow.setWidth(100, Unit.PERCENTAGE); { Label treatmentsLabel = new Label(I18nProperties.getString(Strings.headingTreatments)); CssStyles.style(treatmentsLabel, CssStyles.H3); headlineRow.addComponent(treatmentsLabel); headlineRow.setExpandRatio(treatmentsLabel, 1); // Bulk operations if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getTherapyController() .deleteAllSelectedTreatments(treatmentGrid.getSelectedRows(), new Runnable() { public void run() { reloadTreatmentGrid(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); headlineRow.addComponent(bulkOperationsDropdown); headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT); } Button newTreatmentButton = new Button(I18nProperties.getCaption(Captions.treatmentNewTreatment)); newTreatmentButton.addClickListener(e -> { ControllerProvider.getTherapyController().openTreatmentCreateForm(treatmentCriteria.getTherapy(), this::reloadTreatmentGrid); }); headlineRow.addComponent(newTreatmentButton); headlineRow.setComponentAlignment(newTreatmentButton, Alignment.MIDDLE_RIGHT); } treatmentsHeader.addComponent(headlineRow); HorizontalLayout filterRow = new HorizontalLayout(); filterRow.setMargin(false); filterRow.setSpacing(true); { treatmentTypeFilter = new ComboBox(); treatmentTypeFilter.setWidth(140, Unit.PIXELS); treatmentTypeFilter.setInputPrompt( I18nProperties.getPrefixCaption(TreatmentDto.I18N_PREFIX, TreatmentDto.TREATMENT_TYPE)); treatmentTypeFilter.addItems((Object[]) TreatmentType.values()); treatmentTypeFilter.addValueChangeListener(e -> { treatmentCriteria.treatmentType(((TreatmentType) e.getProperty().getValue())); navigateTo(treatmentCriteria); }); filterRow.addComponent(treatmentTypeFilter); treatmentTextFilter = new TextField(); treatmentTextFilter.setWidth(300, Unit.PIXELS); treatmentTextFilter.setNullRepresentation(""); treatmentTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptTreatmentTextFilter)); treatmentTextFilter.addTextChangeListener(e -> { treatmentCriteria.textFilter(e.getText()); reloadTreatmentGrid(); }); filterRow.addComponent(treatmentTextFilter); } treatmentsHeader.addComponent(filterRow); return treatmentsHeader; }