ItEr28S11AltaEtiquetasTipoEtiquetaItEr27S11: [FixBug] Bandbox search label for label name and label type name

This commit is contained in:
Diego Pino Garcia 2009-10-04 19:18:15 +02:00 committed by Javier Moran Rua
parent 78f18bd877
commit d3759e7ccc

View file

@ -132,18 +132,24 @@ public class AssignedLabelsToOrderElementController extends
*/
public void onSearchLabels(InputEvent event) {
bdLabels.setVariable("selectedLabel", null, true);
List<Label> filteredLabels = labelsStartWith(event.getValue());
List<Label> filteredLabels = matchesString(event.getValue());
lbLabels.setModel(new SimpleListModel(filteredLabels));
lbLabels.invalidate();
}
/**
* Find {@link Label} which name or type start with prefix
*
* @param prefix
*/
@SuppressWarnings("unchecked")
private List<Label> labelsStartWith(String prefix) {
private List<Label> matchesString(String prefix) {
List<Label> result = new ArrayList<Label>();
List<Label> labels = (List<Label>) bdLabels.getVariable("allLabels",
true);
for (Label label : labels) {
if (label.getName().startsWith(prefix)) {
if (label.getName().contains(prefix)
|| label.getType().getName().contains(prefix)) {
result.add(label);
}
}