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();
});
}
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());
});
}
}
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());
});
}
}
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());
}
Aggregations