Search in sources :

Example 1 with DescriptionGenerator

use of com.vaadin.ui.DescriptionGenerator in project SORMAS-Project by hzi-braunschweig.

the class CaseFollowUpGrid method setVisitColumns.

public void setVisitColumns(CaseCriteria criteria) {
    Date referenceDate = criteria.getFollowUpVisitsTo();
    int interval = criteria.getFollowUpVisitsInterval();
    setDataProvider(referenceDate, interval - 1);
    setCriteria(criteria);
    dates.forEach(date -> removeColumn(DateFormatHelper.formatDate(date)));
    setDates(referenceDate, interval);
    for (int i = 0; i < interval; i++) {
        String columnId = DateFormatHelper.formatDate(dates.get(i));
        addComponentColumn(followUpDto -> new Label("")).setId(columnId);
        final int index = i;
        getColumn(columnId).setCaption(columnId).setSortable(false).setStyleGenerator((StyleGenerator<CaseFollowUpDto>) item -> {
            final VisitResultDto visitResult = item.getVisitResults()[index];
            final Date date = dates.get(index);
            return getVisitResultCssStyle(visitResult, date, item.getReportDate(), item.getFollowUpUntil());
        }).setDescriptionGenerator((DescriptionGenerator<CaseFollowUpDto>) item -> {
            final VisitResultDto visitResult = item.getVisitResults()[index];
            final Date date = dates.get(index);
            return getVisitResultDescription(visitResult, date, item.getReportDate(), item.getFollowUpUntil());
        });
    }
}
Also used : UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) FollowUpUtils.getVisitResultDescription(de.symeda.sormas.ui.utils.FollowUpUtils.getVisitResultDescription) Date(java.util.Date) DescriptionGenerator(com.vaadin.ui.DescriptionGenerator) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) DateFormatHelper(de.symeda.sormas.ui.utils.DateFormatHelper) CaseFollowUpDto(de.symeda.sormas.api.caze.CaseFollowUpDto) DateHelper(de.symeda.sormas.api.utils.DateHelper) SortDirection(com.vaadin.shared.data.sort.SortDirection) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ArrayList(java.util.ArrayList) FollowUpDto(de.symeda.sormas.api.followup.FollowUpDto) Label(com.vaadin.ui.Label) DataProvider(com.vaadin.data.provider.DataProvider) DateRenderer(com.vaadin.ui.renderers.DateRenderer) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) SortProperty(de.symeda.sormas.api.utils.SortProperty) Collectors(java.util.stream.Collectors) List(java.util.List) VisitResultDto(de.symeda.sormas.api.visit.VisitResultDto) FollowUpUtils.getVisitResultCssStyle(de.symeda.sormas.ui.utils.FollowUpUtils.getVisitResultCssStyle) StyleGenerator(com.vaadin.ui.StyleGenerator) View(com.vaadin.navigator.View) StyleGenerator(com.vaadin.ui.StyleGenerator) Label(com.vaadin.ui.Label) VisitResultDto(de.symeda.sormas.api.visit.VisitResultDto) Date(java.util.Date) CaseFollowUpDto(de.symeda.sormas.api.caze.CaseFollowUpDto)

Example 2 with DescriptionGenerator

use of com.vaadin.ui.DescriptionGenerator in project SORMAS-Project by hzi-braunschweig.

the class ContactFollowUpGrid method setVisitColumns.

public void setVisitColumns(ContactCriteria criteria) {
    Date referenceDate = criteria.getFollowUpVisitsTo();
    int interval = criteria.getFollowUpVisitsInterval();
    setDataProvider(referenceDate, interval - 1);
    setCriteria(criteria);
    dates.forEach(date -> removeColumn(DateFormatHelper.formatDate(date)));
    setDates(referenceDate, interval);
    dateColumnIds.clear();
    for (int i = 0; i < interval; i++) {
        String columnId = DateFormatHelper.formatDate(dates.get(i));
        dateColumnIds.add(columnId);
        addComponentColumn(followUpDto -> new Label("")).setId(columnId);
        final int index = i;
        getColumn(columnId).setCaption(columnId).setSortable(false).setStyleGenerator((StyleGenerator<ContactFollowUpDto>) item -> {
            final VisitResultDto visitResult = item.getVisitResults()[index];
            final Date date = dates.get(index);
            return getVisitResultCssStyle(visitResult, date, ContactLogic.getStartDate(item.getLastContactDate(), item.getReportDate()), item.getFollowUpUntil());
        }).setDescriptionGenerator((DescriptionGenerator<ContactFollowUpDto>) item -> {
            final VisitResultDto visitResult = item.getVisitResults()[index];
            final Date date = dates.get(index);
            return getVisitResultDescription(visitResult, date, ContactLogic.getStartDate(item.getLastContactDate(), item.getReportDate()), item.getFollowUpUntil());
        });
    }
}
Also used : ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) FollowUpUtils.getVisitResultDescription(de.symeda.sormas.ui.utils.FollowUpUtils.getVisitResultDescription) Date(java.util.Date) DescriptionGenerator(com.vaadin.ui.DescriptionGenerator) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) DateFormatHelper(de.symeda.sormas.ui.utils.DateFormatHelper) DateHelper(de.symeda.sormas.api.utils.DateHelper) SortDirection(com.vaadin.shared.data.sort.SortDirection) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ArrayList(java.util.ArrayList) FollowUpDto(de.symeda.sormas.api.followup.FollowUpDto) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) FieldAccessColumnStyleGenerator(de.symeda.sormas.ui.utils.FieldAccessColumnStyleGenerator) Label(com.vaadin.ui.Label) DataProvider(com.vaadin.data.provider.DataProvider) ContactFollowUpDto(de.symeda.sormas.api.contact.ContactFollowUpDto) DateRenderer(com.vaadin.ui.renderers.DateRenderer) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) ContactLogic(de.symeda.sormas.api.contact.ContactLogic) SortProperty(de.symeda.sormas.api.utils.SortProperty) Collectors(java.util.stream.Collectors) ShowDetailsListener(de.symeda.sormas.ui.utils.ShowDetailsListener) List(java.util.List) VisitResultDto(de.symeda.sormas.api.visit.VisitResultDto) FollowUpUtils.getVisitResultCssStyle(de.symeda.sormas.ui.utils.FollowUpUtils.getVisitResultCssStyle) StyleGenerator(com.vaadin.ui.StyleGenerator) View(com.vaadin.navigator.View) FieldAccessColumnStyleGenerator(de.symeda.sormas.ui.utils.FieldAccessColumnStyleGenerator) StyleGenerator(com.vaadin.ui.StyleGenerator) ContactFollowUpDto(de.symeda.sormas.api.contact.ContactFollowUpDto) Label(com.vaadin.ui.Label) VisitResultDto(de.symeda.sormas.api.visit.VisitResultDto) Date(java.util.Date)

Example 3 with DescriptionGenerator

use of com.vaadin.ui.DescriptionGenerator in project catma by forTEXT.

the class AnnotationDetailsPanel method initComponents.

private void initComponents() {
    setSpacing(true);
    setMargin(false);
    setSizeFull();
    addStyleName("annotation-details-panel");
    HorizontalLayout headerPanel = new HorizontalLayout();
    headerPanel.setWidth("100%");
    addComponent(headerPanel);
    btClearSelected = new IconButton(VaadinIcons.ERASER);
    btClearSelected.setDescription("Clear the list of selected Annotations");
    headerPanel.addComponent(btClearSelected);
    headerPanel.setComponentAlignment(btClearSelected, Alignment.TOP_RIGHT);
    headerPanel.setExpandRatio(btClearSelected, 1.0f);
    btMinimize = new IconButton(VaadinIcons.ANGLE_DOUBLE_DOWN);
    headerPanel.addComponent(btMinimize);
    headerPanel.setComponentAlignment(btMinimize, Alignment.TOP_RIGHT);
    annotationDetailData = new TreeData<>();
    annotationDetailsProvider = new TreeDataProvider<>(annotationDetailData);
    annotationDetailsTree = TreeGridFactory.createDefaultGrid(annotationDetailsProvider);
    annotationDetailsTree.setSizeFull();
    annotationDetailsTree.addStyleNames("annotation-details-panel-annotation-details-grid", "flat-undecorated-icon-buttonrenderer");
    annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getDetail(), new HtmlRenderer()).setCaption("Annotation").setWidth(200).setSortable(false);
    annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getTag()).setCaption("Tag").setSortable(false).setWidth(80);
    annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getAuthor()).setCaption("Author").setSortable(false).setWidth(60);
    annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getCollection()).setCaption("Collection").setSortable(false).setWidth(60);
    annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getTagset()).setCaption("Tagset").setSortable(false).setWidth(70);
    annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getAnnotationId()).setCaption("Annotation ID").setHidable(true).setHidden(true).setSortable(false).setWidth(100);
    ButtonRenderer<AnnotationTreeItem> editAnnotationRenderer = new ButtonRenderer<AnnotationTreeItem>(clickEvent -> handleEditAnnotationRequest(clickEvent));
    editAnnotationRenderer.setHtmlContentAllowed(true);
    annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getEditIcon(), editAnnotationRenderer).setWidth(50);
    ButtonRenderer<AnnotationTreeItem> deleteAnnotationRenderer = new ButtonRenderer<AnnotationTreeItem>(clickEvent -> handleDeleteAnnotationRequest(clickEvent));
    deleteAnnotationRenderer.setHtmlContentAllowed(true);
    annotationDetailsTree.addColumn(annotationTreeItem -> annotationTreeItem.getDeleteIcon(), deleteAnnotationRenderer).setExpandRatio(1);
    annotationDetailsTree.setDescriptionGenerator(new DescriptionGenerator<AnnotationTreeItem>() {

        @Override
        public String apply(AnnotationTreeItem annotationTreeItem) {
            return annotationTreeItem.getDescription();
        }
    }, ContentMode.HTML);
    ActionGridComponent<TreeGrid<AnnotationTreeItem>> annotationDetailsGridComponent = new ActionGridComponent<>(new Label("Selected Annotations"), annotationDetailsTree);
    annotationDetailsGridComponent.setMargin(false);
    addComponent(annotationDetailsGridComponent);
    setExpandRatio(annotationDetailsGridComponent, 1.0f);
}
Also used : SelectionEvent(com.vaadin.event.selection.SelectionEvent) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) ConfirmDialog(org.vaadin.dialogs.ConfirmDialog) KwicProvider(de.catma.indexer.KwicProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) VaadinIcons(com.vaadin.icons.VaadinIcons) Objects(com.google.common.base.Objects) IconButton(de.catma.ui.component.IconButton) Collection(java.util.Collection) Set(java.util.Set) TagInstance(de.catma.tag.TagInstance) TreeGrid(com.vaadin.ui.TreeGrid) Collectors(java.util.stream.Collectors) List(java.util.List) Type(com.vaadin.ui.Notification.Type) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) PropertyChangeListener(java.beans.PropertyChangeListener) TagDefinition(de.catma.tag.TagDefinition) Optional(java.util.Optional) RBACPermission(de.catma.rbac.RBACPermission) PropertyDefinition(de.catma.tag.PropertyDefinition) ClickListener(com.vaadin.ui.Button.ClickListener) DescriptionGenerator(com.vaadin.ui.DescriptionGenerator) VerticalLayout(com.vaadin.ui.VerticalLayout) AnnotationCollectionManager(de.catma.document.annotation.AnnotationCollectionManager) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Registration(com.vaadin.shared.Registration) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) TreeGridFactory(de.catma.ui.component.TreeGridFactory) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) ContentMode(com.vaadin.shared.ui.ContentMode) Property(de.catma.tag.Property) TreeData(com.vaadin.data.TreeData) Project(de.catma.project.Project) RepositoryChangeEvent(de.catma.project.Project.RepositoryChangeEvent) IOException(java.io.IOException) SourceDocument(de.catma.document.source.SourceDocument) Annotation(de.catma.document.annotation.Annotation) Consumer(java.util.function.Consumer) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ScrollDestination(com.vaadin.shared.ui.grid.ScrollDestination) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) Label(com.vaadin.ui.Label) HorizontalLayout(com.vaadin.ui.HorizontalLayout) IconButton(de.catma.ui.component.IconButton) TreeGrid(com.vaadin.ui.TreeGrid) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Aggregations

DescriptionGenerator (com.vaadin.ui.DescriptionGenerator)3 Label (com.vaadin.ui.Label)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 DataProvider (com.vaadin.data.provider.DataProvider)2 View (com.vaadin.navigator.View)2 SortDirection (com.vaadin.shared.data.sort.SortDirection)2 StyleGenerator (com.vaadin.ui.StyleGenerator)2 DateRenderer (com.vaadin.ui.renderers.DateRenderer)2 Objects (com.google.common.base.Objects)1 TreeData (com.vaadin.data.TreeData)1 TreeDataProvider (com.vaadin.data.provider.TreeDataProvider)1 SelectionEvent (com.vaadin.event.selection.SelectionEvent)1 VaadinIcons (com.vaadin.icons.VaadinIcons)1 Registration (com.vaadin.shared.Registration)1 ContentMode (com.vaadin.shared.ui.ContentMode)1 ScrollDestination (com.vaadin.shared.ui.grid.ScrollDestination)1 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1