use of org.jowidgets.cap.ui.api.filter.IUiFilter in project jo-client-platform by jo-source.
the class UiFilterToolsImpl method removeProperty.
@SuppressWarnings("unchecked")
@Override
public IUiFilter removeProperty(final IUiFilter sourceFilter, final String propertyName) {
Assert.paramNotNull(sourceFilter, "sourceFilter");
Assert.paramNotNull(propertyName, "propertyName");
final IUiFilterFactory filterFactory = CapUiToolkit.filterToolkit().filterFactory();
if (sourceFilter instanceof IUiBooleanFilter) {
boolean empty = true;
final IUiBooleanFilter source = (IUiBooleanFilter) sourceFilter;
final IUiBooleanFilterBuilder builder = filterFactory.booleanFilterBuilder();
builder.setOperator(source.getOperator());
builder.setInverted(source.isInverted());
for (final IUiFilter childFilter : source.getFilters()) {
final IUiFilter childResultFilter = removeProperty(childFilter, propertyName);
if (childResultFilter != null) {
builder.addFilter(childResultFilter);
empty = false;
}
}
if (empty) {
return null;
} else {
return builder.build();
}
} else if (sourceFilter instanceof IUiArithmeticFilter<?>) {
final IUiArithmeticFilter<Object> source = (IUiArithmeticFilter<Object>) sourceFilter;
if (propertyName.equals(source.getPropertyName())) {
return null;
} else {
return source;
}
} else if (sourceFilter instanceof IUiArithmeticPropertyFilter<?>) {
final IUiArithmeticPropertyFilter<Object> source = (IUiArithmeticPropertyFilter<Object>) sourceFilter;
if (propertyName.equals(source.getPropertyName())) {
return null;
} else {
return source;
}
} else if (sourceFilter instanceof IUiCustomFilter<?>) {
final IUiCustomFilter<Object> source = (IUiCustomFilter<Object>) sourceFilter;
if (propertyName.equals(source.getPropertyName())) {
return null;
} else {
return source;
}
} else {
throw new IllegalArgumentException("The source filter type '" + sourceFilter.getClass().getName() + "' is not supported");
}
}
use of org.jowidgets.cap.ui.api.filter.IUiFilter in project jo-client-platform by jo-source.
the class UiFilterToolsImpl method toHumanReadable.
private StringBuilder toHumanReadable(final IUiBooleanFilter filter, final Map<String, String> attributeMap) {
final StringBuilder result = new StringBuilder();
if (filter.getFilters().size() > 0) {
int effectiveSize = 0;
if (filter.isInverted()) {
result.append("not (");
}
for (final IUiFilter subFilter : filter.getFilters()) {
result.append('(');
result.append(toHumanReadable(subFilter, attributeMap));
result.append(')');
effectiveSize = result.length();
result.append(' ');
result.append(filter.getOperator().getLabel());
result.append(' ');
}
result.setLength(effectiveSize);
if (filter.isInverted()) {
result.append(')');
}
}
return result;
}
use of org.jowidgets.cap.ui.api.filter.IUiFilter in project jo-client-platform by jo-source.
the class BeanRelationNodeModelImpl method addFilter.
@Override
public void addFilter(final String id, final IUiFilter addedFilter) {
Assert.paramNotNull(id, "id");
Assert.paramNotNull(addedFilter, "addedFilter");
final IUiFilterTools filterTools = CapUiToolkit.filterToolkit().filterTools();
final IUiFilter currentFilter = getFilter(id);
setFilter(id, filterTools.addFilter(currentFilter, addedFilter));
}
use of org.jowidgets.cap.ui.api.filter.IUiFilter in project jo-client-platform by jo-source.
the class BeanTabFolderModelImpl method addFilter.
@Override
public void addFilter(final String id, final IUiFilter addedFilter) {
Assert.paramNotNull(id, "id");
Assert.paramNotNull(addedFilter, "addedFilter");
final IUiFilterTools filterTools = CapUiToolkit.filterToolkit().filterTools();
final IUiFilter currentFilter = getFilter(id);
setFilter(id, filterTools.addFilter(currentFilter, addedFilter));
}
use of org.jowidgets.cap.ui.api.filter.IUiFilter in project jo-client-platform by jo-source.
the class BeanTabFolderModelImpl method getFilter.
private IFilter getFilter() {
if (filters.size() > 0) {
final IBooleanFilterBuilder builder = CapCommonToolkit.filterFactory().booleanFilterBuilder();
builder.setOperator(BooleanOperator.AND);
final IUiFilterFactory filterFactory = CapUiToolkit.filterToolkit().filterFactory();
for (final IUiFilter uiFilter : filters.values()) {
builder.addFilter(filterFactory.convert(uiFilter));
}
return builder.build();
} else {
return null;
}
}
Aggregations