Search in sources :

Example 1 with StyleGenerator

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

the class TagsView method initActions.

private void initActions() {
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getColor(), new HtmlRenderer()).setCaption("Tagsets").setSortable(false).setWidth(200);
    tagsetGrid.setHierarchyColumn(tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getName()).setCaption("Tags").setSortable(false).setWidth(300));
    ButtonRenderer<TagsetTreeItem> propertySummaryRenderer = new ButtonRenderer<>(rendererClickEvent -> handlePropertySummaryClickEvent(rendererClickEvent));
    propertySummaryRenderer.setHtmlContentAllowed(true);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertySummary(), propertySummaryRenderer).setCaption("Properties").setSortable(false).setHidable(true).setWidth(300);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertyValue()).setCaption("Values").setSortable(false).setHidable(true).setWidth(300);
    ButtonRenderer<TagsetTreeItem> btRemovalRenderer = new ButtonRenderer<>(rendererClickEvent -> handleTagsetTreeItemRemovalRequest(rendererClickEvent));
    btRemovalRenderer.setHtmlContentAllowed(true);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getRemoveIcon()).setRenderer(btRemovalRenderer).setSortable(false).setHidable(false).setExpandRatio(1);
    tagsetGrid.setStyleGenerator(new StyleGenerator<TagsetTreeItem>() {

        @Override
        public String apply(TagsetTreeItem item) {
            return item.generateStyle();
        }
    });
    tagsetGridComponent.setSearchFilterProvider(new SearchFilterProvider<TagsetTreeItem>() {

        @Override
        public SerializablePredicate<TagsetTreeItem> createSearchFilter(String searchInput) {
            return new TagsetSearchFilterProvider(searchInput, tagsetData);
        }
    });
    tagsetGrid.addExpandListener(expandEvent -> handleExpandCollapseTagset(expandEvent.getExpandedItem(), true));
    tagsetGrid.addCollapseListener(collapseEvent -> handleExpandCollapseTagset(collapseEvent.getCollapsedItem(), false));
    ContextMenu addContextMenu = tagsetGridComponent.getActionGridBar().getBtnAddContextMenu();
    addContextMenu.addItem("Add Tagset", clickEvent -> handleAddTagsetRequest());
    addContextMenu.addItem("Add Tag", clickEvent -> handleAddTagRequest());
    addContextMenu.addItem("Add Subtag", clickEvent -> handleAddSubtagRequest());
    addContextMenu.addItem("Add Property", clickEvent -> handleAddPropertyRequest());
    ContextMenu moreOptionsContextMenu = tagsetGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    moreOptionsContextMenu.addItem("Edit Tag", clickEvent -> handleEditTagRequest());
    moreOptionsContextMenu.addItem("Delete Tag", clickEvent -> handleDeleteTagRequest());
    moreOptionsContextMenu.addItem("Edit/Delete Properties", clickEvent -> handleEditPropertiesRequest());
    moreOptionsContextMenu.addItem("Edit Tagset", clickEvent -> handleEditTagsetRequest());
    moreOptionsContextMenu.addItem("Delete Tagset", clickEvent -> handleDeleteTagsetRequest());
    resourcePanel.setTagsetSelectionListener(selectedTagsets -> {
        tagsets.clear();
        tagsets.addAll(selectedTagsets);
        initData();
    });
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) PropertyDefinition(de.catma.tag.PropertyDefinition) UI(com.vaadin.ui.UI) ConfirmDialog(org.vaadin.dialogs.ConfirmDialog) Multimap(com.google.common.collect.Multimap) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) ArrayList(java.util.ArrayList) EventBus(com.google.common.eventbus.EventBus) MaterialTheme(com.github.appreciated.material.MaterialTheme) Notification(com.vaadin.ui.Notification) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Label(com.vaadin.ui.Label) TagsetDefinition(de.catma.tag.TagsetDefinition) SliderPanel(org.vaadin.sliderpanel.SliderPanel) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) Pair(de.catma.util.Pair) Version(de.catma.tag.Version) TreeGridFactory(de.catma.ui.component.TreeGridFactory) IDGenerator(de.catma.util.IDGenerator) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) TreeData(com.vaadin.data.TreeData) Project(de.catma.project.Project) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) TreeGrid(com.vaadin.ui.TreeGrid) Collectors(java.util.stream.Collectors) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) ContextMenu(com.vaadin.contextmenu.ContextMenu) List(java.util.List) Type(com.vaadin.ui.Notification.Type) RendererClickEvent(com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent) PropertyChangeListener(java.beans.PropertyChangeListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TagDefinition(de.catma.tag.TagDefinition) SerializablePredicate(com.vaadin.server.SerializablePredicate) Optional(java.util.Optional) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) SliderPanelBuilder(org.vaadin.sliderpanel.SliderPanelBuilder) SelectionMode(com.vaadin.ui.Grid.SelectionMode) StyleGenerator(com.vaadin.ui.StyleGenerator) RBACPermission(de.catma.rbac.RBACPermission) SliderMode(org.vaadin.sliderpanel.client.SliderMode) HugeCard(de.catma.ui.component.hugecard.HugeCard) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SerializablePredicate(com.vaadin.server.SerializablePredicate) ContextMenu(com.vaadin.contextmenu.ContextMenu) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Example 2 with StyleGenerator

use of com.vaadin.ui.StyleGenerator 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 3 with StyleGenerator

use of com.vaadin.ui.StyleGenerator 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 4 with StyleGenerator

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

the class AnnotationPanel method initActions.

private void initActions(Consumer<AnnotationCollection> collectionSelectionListener, Consumer<TagDefinition> tagSelectionListener) {
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getColor(), new HtmlRenderer()).setCaption("Tagsets").setSortable(false).setWidth(100);
    tagsetGrid.setHierarchyColumn(tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getName()).setCaption("Tags").setSortable(false).setWidth(200));
    ButtonRenderer<TagsetTreeItem> propertySummaryRenderer = new ButtonRenderer<>(rendererClickEvent -> handlePropertySummaryClickEvent(rendererClickEvent));
    propertySummaryRenderer.setHtmlContentAllowed(true);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertySummary(), propertySummaryRenderer).setCaption("Properties").setSortable(false).setHidable(true).setWidth(100);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getPropertyValue()).setCaption("Values").setSortable(false).setHidable(true).setWidth(100);
    ButtonRenderer<TagsetTreeItem> visibilityRenderer = new ButtonRenderer<TagsetTreeItem>(rendererClickEvent -> handleVisibilityClickEvent(rendererClickEvent));
    visibilityRenderer.setHtmlContentAllowed(true);
    tagsetGrid.addColumn(tagsetTreeItem -> tagsetTreeItem.getVisibilityIcon(), visibilityRenderer).setWidth(80).setSortable(false);
    tagsetGrid.setStyleGenerator(new StyleGenerator<TagsetTreeItem>() {

        @Override
        public String apply(TagsetTreeItem item) {
            return item.generateStyle();
        }
    });
    tagsetGridComponent.setSearchFilterProvider(new SearchFilterProvider<TagsetTreeItem>() {

        @Override
        public SerializablePredicate<TagsetTreeItem> createSearchFilter(String searchInput) {
            return new SerializablePredicate<TagsetTreeItem>() {

                @Override
                public boolean test(TagsetTreeItem t) {
                    return testWithChildren(t);
                }

                private boolean testTagsetTreeItem(TagsetTreeItem t) {
                    String strValue = t.toString();
                    if (strValue != null && strValue.toLowerCase().contains(searchInput.toLowerCase())) {
                        return true;
                    }
                    return false;
                }

                public boolean testWithChildren(TagsetTreeItem t) {
                    if (t == null) {
                        return false;
                    }
                    if (testTagsetTreeItem(t)) {
                        return true;
                    }
                    for (TagsetTreeItem child : tagsetData.getChildren(t)) {
                        if (testWithChildren(child)) {
                            return true;
                        }
                    }
                    return false;
                }
            };
        }
    });
    tagsetGrid.addItemClickListener(clickEvent -> handleTagSelection(clickEvent, tagSelectionListener));
    tagsetGrid.addCollapseListener(event -> event.getCollapsedItem().setTagsetExpanded(false));
    tagsetGrid.addExpandListener(event -> event.getExpandedItem().setTagsetExpanded(true));
    ContextMenu addContextMenu = tagsetGridComponent.getActionGridBar().getBtnAddContextMenu();
    addContextMenu.addItem("Add Tag", clickEvent -> handleAddTagRequest());
    addContextMenu.addItem("Add Subtag", clickEvent -> handleAddSubtagRequest());
    addContextMenu.addItem("Add Property", clickEvent -> handleAddPropertyRequest());
    ContextMenu moreOptionsContextMenu = tagsetGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    moreOptionsContextMenu.addItem("Edit Tag", clickEvent -> handleEditTagRequest());
    moreOptionsContextMenu.addItem("Edit/Delete Properties", clickEvent -> handleEditPropertiesRequest());
    currentEditableCollectionBox.addValueChangeListener(event -> collectionSelectionListener.accept(event.getValue()));
    annotationDetailsPanel.addMinimizeButtonClickListener(clickEvent -> setAnnotationDetailsPanelVisible(false));
    btMaximizeAnnotationDetailsRibbon.addClickListener(ClickEvent -> setAnnotationDetailsPanelVisible(true));
    btAddCollection.addClickListener(clickEvent -> handelAddCollectionRequest());
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) VerticalSplitPanel(com.vaadin.ui.VerticalSplitPanel) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) XmlMarkupCollectionSerializationHandler(de.catma.serialization.intrinsic.xml.XmlMarkupCollectionSerializationHandler) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) VaadinIcons(com.vaadin.icons.VaadinIcons) IconButton(de.catma.ui.component.IconButton) Collection(java.util.Collection) Set(java.util.Set) TreeGrid(com.vaadin.ui.TreeGrid) Collectors(java.util.stream.Collectors) ItemClick(com.vaadin.ui.Grid.ItemClick) TagReference(de.catma.document.annotation.TagReference) Objects(java.util.Objects) 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) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) CollectionChangeEvent(de.catma.project.event.CollectionChangeEvent) SelectionMode(com.vaadin.ui.Grid.SelectionMode) StyleGenerator(com.vaadin.ui.StyleGenerator) RBACPermission(de.catma.rbac.RBACPermission) PropertyDefinition(de.catma.tag.PropertyDefinition) VerticalLayout(com.vaadin.ui.VerticalLayout) AnnotationCollectionManager(de.catma.document.annotation.AnnotationCollectionManager) ComboBox(com.vaadin.ui.ComboBox) Multimap(com.google.common.collect.Multimap) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) EventBus(com.google.common.eventbus.EventBus) AddEditPropertyDialog(de.catma.ui.module.tags.AddEditPropertyDialog) MaterialTheme(com.github.appreciated.material.MaterialTheme) EditTagDialog(de.catma.ui.module.tags.EditTagDialog) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) TagsetDefinition(de.catma.tag.TagsetDefinition) Pair(de.catma.util.Pair) TreeGridFactory(de.catma.ui.component.TreeGridFactory) IDGenerator(de.catma.util.IDGenerator) Subscribe(com.google.common.eventbus.Subscribe) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) ListDataProvider(com.vaadin.data.provider.ListDataProvider) TreeData(com.vaadin.data.TreeData) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Project(de.catma.project.Project) AddSubtagDialog(de.catma.ui.module.tags.AddSubtagDialog) IOException(java.io.IOException) AddParenttagDialog(de.catma.ui.module.tags.AddParenttagDialog) SourceDocument(de.catma.document.source.SourceDocument) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) Annotation(de.catma.document.annotation.Annotation) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) ContextMenu(com.vaadin.contextmenu.ContextMenu) Button(com.vaadin.ui.Button) ChangeType(de.catma.project.event.ChangeType) HorizontalLayout(com.vaadin.ui.HorizontalLayout) SerializablePredicate(com.vaadin.server.SerializablePredicate) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SerializablePredicate(com.vaadin.server.SerializablePredicate) ContextMenu(com.vaadin.contextmenu.ContextMenu) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Aggregations

Label (com.vaadin.ui.Label)4 StyleGenerator (com.vaadin.ui.StyleGenerator)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 MaterialTheme (com.github.appreciated.material.MaterialTheme)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)2 Multimap (com.google.common.collect.Multimap)2 EventBus (com.google.common.eventbus.EventBus)2 ContextMenu (com.vaadin.contextmenu.ContextMenu)2 TreeData (com.vaadin.data.TreeData)2 DataProvider (com.vaadin.data.provider.DataProvider)2 TreeDataProvider (com.vaadin.data.provider.TreeDataProvider)2 View (com.vaadin.navigator.View)2 SerializablePredicate (com.vaadin.server.SerializablePredicate)2 SortDirection (com.vaadin.shared.data.sort.SortDirection)2 DescriptionGenerator (com.vaadin.ui.DescriptionGenerator)2 SelectionMode (com.vaadin.ui.Grid.SelectionMode)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Notification (com.vaadin.ui.Notification)2