Search in sources :

Example 1 with Characteristic

use of de.metas.ui.web.window.descriptor.DocumentFieldDescriptor.Characteristic in project metasfresh-webui-api by metasfresh.

the class DocumentFilterDescriptorsProviderFactory method createFiltersProvider_Defaults.

/**
 * Creates standard filters, i.e. from document fields which are flagged with {@link Characteristic#AllowFiltering}.
 *
 * @param fields
 */
private ImmutableDocumentFilterDescriptorsProvider createFiltersProvider_Defaults(final Collection<DocumentFieldDescriptor> fields) {
    final DocumentFilterDescriptor.Builder defaultFilter = DocumentFilterDescriptor.builder().setFilterId(FILTER_ID_Default).setDisplayName(msgBL.getTranslatableMsgText(MSG_DefaultFilterName)).setFrequentUsed(false);
    final DocumentFilterDescriptor.Builder defaultDateFilter = DocumentFilterDescriptor.builder().setFilterId(FILTER_ID_DefaultDate).setFrequentUsed(true);
    final List<DocumentFieldDescriptor> filteringFields = fields.stream().filter(DocumentFieldDescriptor::isDefaultFilterField).sorted(Ordering.natural().onResultOf(field -> field.getDefaultFilterInfo().getSeqNo())).collect(ImmutableList.toImmutableList());
    for (final DocumentFieldDescriptor field : filteringFields) {
        final DocumentFilterParamDescriptor.Builder filterParam = createFilterParam(field);
        if (!defaultDateFilter.hasParameters() && filterParam.getWidgetType().isDateOrTime()) {
            defaultDateFilter.setDisplayName(filterParam.getDisplayName());
            defaultDateFilter.addParameter(filterParam);
        } else {
            defaultFilter.addParameter(filterParam);
        }
    }
    return Stream.of(defaultDateFilter, defaultFilter).filter(filterBuilder -> filterBuilder.hasParameters()).map(filterBuilder -> filterBuilder.build()).collect(ImmutableDocumentFilterDescriptorsProvider.collector());
}
Also used : ITranslatableString(de.metas.i18n.ITranslatableString) DocumentFieldDefaultFilterDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDefaultFilterDescriptor) Collection(java.util.Collection) LookupDescriptorProvider(de.metas.ui.web.window.descriptor.LookupDescriptorProvider) DocumentFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor) Services(org.adempiere.util.Services) List(java.util.List) Stream(java.util.stream.Stream) Operator(de.metas.ui.web.document.filter.DocumentFilterParam.Operator) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor) ImmutableList(com.google.common.collect.ImmutableList) Ordering(com.google.common.collect.Ordering) Characteristic(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor.Characteristic) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) IMsgBL(de.metas.i18n.IMsgBL) Nullable(javax.annotation.Nullable) DocumentFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Ordering (com.google.common.collect.Ordering)1 IMsgBL (de.metas.i18n.IMsgBL)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 Operator (de.metas.ui.web.document.filter.DocumentFilterParam.Operator)1 DocumentFieldDefaultFilterDescriptor (de.metas.ui.web.window.descriptor.DocumentFieldDefaultFilterDescriptor)1 DocumentFieldDescriptor (de.metas.ui.web.window.descriptor.DocumentFieldDescriptor)1 Characteristic (de.metas.ui.web.window.descriptor.DocumentFieldDescriptor.Characteristic)1 DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)1 LookupDescriptor (de.metas.ui.web.window.descriptor.LookupDescriptor)1 LookupDescriptorProvider (de.metas.ui.web.window.descriptor.LookupDescriptorProvider)1 Collection (java.util.Collection)1 List (java.util.List)1 Stream (java.util.stream.Stream)1 Nullable (javax.annotation.Nullable)1 Services (org.adempiere.util.Services)1