Do not refresh project list if filter did not change

Every time key up event is raised in the project list filter text box,
the project list was getting refreshed even if the filter did not
change (e.g. moving the cursor was refreshing the list).

Only call the refresh if the filter changed or if enter key is pressed.

Change-Id: I2e608d89e16dbef0cfe1e503ac2feb4639c27f5d
This commit is contained in:
Hugo Arès
2014-04-07 09:15:02 -04:00
committed by David Pursehouse
parent 72bced0061
commit f79fd10f3b

View File

@@ -43,7 +43,7 @@ import com.google.gwtexpui.globalkey.client.NpTextBox;
public class ProjectListScreen extends Screen implements FilteredUserInterface {
private ProjectsTable projects;
private NpTextBox filterTxt;
private String subname;
private String subname = "";
public ProjectListScreen() {
}
@@ -158,8 +158,12 @@ public class ProjectListScreen extends Screen implements FilteredUserInterface {
filterTxt.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event) {
subname = filterTxt.getValue();
refresh(event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER);
boolean enterPressed =
event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER;
if (enterPressed || !filterTxt.getValue().equals(subname)) {
subname = filterTxt.getValue();
refresh(enterPressed);
}
}
});
hp.add(filterTxt);