public class MyDataGrid<T> extends DataGrid<T> {
private Set<T> priorSelectionSet_;
....
/**
* Allows User To Deselect A DataGrid Row By Clicking A Second Time On The Prior Selection
*/
private void addDeselectMechanism(){
/*
NOTES:
1. ClickHandler() fires every time the grid is clicked.
2. selectionModel SelectionChangeHandler() does NOT fire when clicking
a row that is already selected.
3. Generally, ClickHandler() fires and then SelectionChangeHandler() fires,
but testing showed some exceptions to this order and duplicate firings.
4. The Current SelectedSet is Updated AFTER the ClickHandler() fires, so "natural"
ClickHandler() timing does not permit current SelectedSet inspections.
5. In this case, the scheduleDeferred() code will ALWAYS fires when a grid is clicked,
it will fire at a PREDICTABLE time, and AFTER the current SelectedSet has been updated.
*/
super.addHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Set<T> currentSelectedSet = selectionModel_.getSelectedSet();
if( (currentSelectedSet.size() == 1) &&
(priorSelectionSet_ != null) ){
if( (currentSelectedSet.size() == priorSelectionSet_.size()) &&
(currentSelectedSet.containsAll( priorSelectionSet_ ) ) ){
selectionModel_.clear();
}
}
priorSelectionSet_ = new HashSet<T>();
priorSelectionSet_.addAll( selectionModel_.getSelectedSet() );
}
});
}
}, ClickEvent.getType());
}
.....
}
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment