[Dive4elements-commits] [PATCH 3 of 8] Fix filtering of Collections/Projects in the gui
Wald Commits
scm-commit at wald.intevation.org
Mon Dec 17 16:19:15 CET 2012
# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1355757222 -3600
# Node ID 62091b0ef789d031c31fc24e5cc3bcda921f312a
# Parent 7c59baa150bdde44503074ddd0fb74f0981d5db8
Fix filtering of Collections/Projects in the gui
The filter was reseted after each reloading of the users collections.
diff -r 7c59baa150bd -r 62091b0ef789 flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Mon Dec 17 16:11:48 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Mon Dec 17 16:13:42 2012 +0100
@@ -164,15 +164,14 @@
/** All user collections.*/
protected List<Collection> collections;
- /** The collections visible in the grid.*/
- protected List<Collection> filteredCollections;
-
/** The collection to clone*/
protected Collection cloneCollection;
/** The message class that provides i18n strings.*/
protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
+ private String filter;
+
/**
* The default constructor that creates a new ProjectList for a specific
@@ -185,7 +184,6 @@
this.flys = flys;
this.user = user;
- filteredCollections = new ArrayList<Collection>();
collections = new ArrayList<Collection>();
grid = new ListGrid();
initGrid();
@@ -444,17 +442,9 @@
@Override
public void onFilterCriteriaChanged(StringFilterEvent event) {
String search = event.getFilter();
- if (search != null && search.length() > 0) {
- // Filter the records.
- filterCollections(search);
- }
- else {
- filteredCollections.clear();
- for(int i = 0; i < collections.size(); i++) {
- filteredCollections.add(collections.get(i));
- }
- updateGrid();
- }
+ // Filter the records.
+ setFilter(search);
+ updateGrid();
}
@@ -675,7 +665,7 @@
for (Collection coll : c) {
this.collections.add(coll);
}
- filterCollections("");
+ updateGrid();
}
@@ -690,45 +680,20 @@
return;
}
- for (Collection c: filteredCollections) {
- grid.addData(new CollectionRecord(c));
+ for (Collection col: collections) {
+ String name;
+
+ name = col.getDisplayName().toLowerCase();
+
+ // Add a collection to the filtered list if the search string
+ // matches.
+ if (filter == null || filter.isEmpty() ||
+ name.contains(filter.toLowerCase())) {
+ grid.addData(new CollectionRecord(col));
+ }
}
}
-
- /**
- * Filter for the user collections.
- *
- * @param search String to search for in collection names.
- */
- protected void filterCollections(String search) {
- // Clear the collection list.
- filteredCollections.clear();
-
- // Filter the list.
- for (int i = 0; i < collections.size(); i++) {
- String name;
-
- // Get the collection name.
- if (collections.get(i).getName().equals("") ||
- collections.get(i).getName() == null) {
- name = collections.get(i).identifier();
- }
- else {
- name = collections.get(i).getName();
- }
-
- name = name.toLowerCase();
- // Add a collection to the filtered list if the search string
- // matches.
- if (name.contains(search.toLowerCase())) {
- filteredCollections.add(collections.get(i));
- }
- }
- updateGrid();
- }
-
-
public int getMaxNameLength() {
return MAX_NAME_LENGTH;
}
@@ -979,5 +944,9 @@
this.flys.shoHeaderProjectButton();
}
}
+
+ private void setFilter(String filter) {
+ this.filter = filter;
+ }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Dive4elements-commits
mailing list