ItEr46S19CUProcuraOrganizacionsTraballoItEr40S22: Added filter by name to order elements tree.

This commit is contained in:
Manuel Rego Casasnovas 2010-02-04 15:30:36 +01:00 committed by Javier Moran Rua
parent 193ce0602d
commit e55564a02e
3 changed files with 29 additions and 4 deletions

View file

@ -23,6 +23,7 @@ package org.navalplanner.web.orders;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.navalplanner.business.labels.entities.Label;
import org.navalplanner.business.orders.entities.OrderElement;
import org.navalplanner.business.requirements.entities.CriterionRequirement;
@ -42,11 +43,14 @@ public class OrderElementPredicate implements IPredicate {
private Date finishDate;
private String name;
public OrderElementPredicate(List<FilterPair> filters, Date startDate,
Date finishDate) {
Date finishDate, String name) {
this.filters = filters;
this.startDate = startDate;
this.finishDate = finishDate;
this.name = name;
}
@Override
@ -59,7 +63,8 @@ public class OrderElementPredicate implements IPredicate {
if (orderElement == null) {
return false;
}
if (acceptFilters(orderElement) && acceptFiltersDates(orderElement)) {
if (acceptFilters(orderElement) && acceptFiltersDates(orderElement)
&& acceptFilterName(orderElement)) {
return true;
}
return false;
@ -173,4 +178,16 @@ public class OrderElementPredicate implements IPredicate {
return false;
}
private boolean acceptFilterName(OrderElement orderElement) {
if (name == null) {
return true;
}
if ((orderElement.getName() != null)
&& (StringUtils
.containsIgnoreCase(orderElement.getName(), name))) {
return true;
}
return false;
}
}

View file

@ -84,6 +84,8 @@ public class OrderElementTreeController extends TreeController<OrderElement> {
private Datebox filterFinishDate2;
private Textbox filterName;
private OrderElementTreeitemRenderer renderer = new OrderElementTreeitemRenderer();
private final IOrderModel orderModel;
@ -200,6 +202,7 @@ public class OrderElementTreeController extends TreeController<OrderElement> {
.getFellow("filterStartDate2");
filterFinishDate2 = (Datebox) filterComponent
.getFellow("filterFinishDate2");
filterName = (Textbox) filterComponent.getFellow("filterName");
templateFinderPopup = (TemplateFinderPopup) comp
.getFellow("templateFinderPopupAtTree");
@ -465,11 +468,14 @@ public class OrderElementTreeController extends TreeController<OrderElement> {
.getSelectedElements();
Date startDate = filterStartDate2.getValue();
Date finishDate = filterFinishDate2.getValue();
String name = filterName.getValue();
if (listFilters.isEmpty() && startDate == null && finishDate == null) {
if (listFilters.isEmpty() && startDate == null && finishDate == null
&& name == null) {
return null;
}
return new OrderElementPredicate(listFilters, startDate, finishDate);
return new OrderElementPredicate(listFilters, startDate, finishDate,
name);
}
private void filterByPredicate(OrderElementPredicate predicate) {

View file

@ -7,6 +7,8 @@
<datebox id="filterStartDate2" constraint = "@{treeController.checkConstraintStartDate}"/>
<label value="${i18n:_('to')}"/>
<datebox id="filterFinishDate2" constraint = "@{treeController.checkConstraintFinishDate}"/>
<label value="${i18n:_('with name likes')}"/>
<textbox id="filterName" />
<button label="${i18n:_('Filter')}" style="margin-top: -4px"
tooltiptext="${i18n:_('Apply filtering to order elements satisfying required critera')}"
onClick="treeController.onApplyFilter()"/>