added a few TODOs for Lukas

This commit is contained in:
Axel Uhl committed 2015-11-25 17:51:29 +01:00
1 parent 3dbbe1c0ad
commit 6912ae8d34
3 files changed
+9 -7

No files matched your search

@@ -7,7 +7,7 @@ import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.ProvidesKey;
public class RefreshableMultiSelectionModel<T> extends MultiSelectionModel<T> implements RefreshableSelectionModel<T> {
private EntityIdentityComparator<T> comp;
private final EntityIdentityComparator<T> comp;
public RefreshableMultiSelectionModel() {
super();
@@ -31,7 +31,7 @@ public class RefreshableMultiSelectionModel<T> extends MultiSelectionModel<T> im
@Override
public void refreshSelectionModel(Iterable<T> newObjects) {
final Set<T> selectedSet = new HashSet<>(getSelectedSet());
final Set<T> selectedSet = new HashSet<>(getSelectedSet()); // TODO Lukas: a copy doesn't seem required (anymore?) here; the result of getSelectedSet() is not referenced beyond the scope of this method
final boolean isNotEmpty = !selectedSet.isEmpty();
clear();
if (isNotEmpty) {
@@ -5,11 +5,13 @@ import com.google.gwt.view.client.SetSelectionModel;
import com.google.gwt.view.client.SingleSelectionModel;
/**
* The Interface {@link RefreshableSelectionModel} unify the refresh behavior of SelectionModels e.g. of a
* The interface {@link RefreshableSelectionModel} unifies the refresh behavior of SelectionModels e.g. of a
* {@link SingleSelectionModel}. To refresh this SelectionModel you can call the
* {@link RefreshableSelectionModel#refreshSelectionModel(Iterable)} method and this method will refresh the
* SelectionModel.
*
* TODO Lukas, please enhance this comment to explain how this re-establishes the invariant of same elements in SetSelectionModel.getSelectedElements and DataProvider
*
* @author D064976
*/
@@ -27,7 +29,7 @@ public interface RefreshableSelectionModel<T> extends SetSelectionModel<T> {
* has no {@link EntityIdentityComparator} set, this method will use the {@link #equals(Object)} method to compare.
* <p>
*
* If an selected object is not in the <code>newObjects</code> the object wouldn't be selected anymore.
* If a selected object is not contained in <code>newObjects</code> the object wouldn't be selected anymore.
* <p>
*
* When the selection is refreshed this method triggers a
@@ -7,7 +7,7 @@ import com.google.gwt.view.client.ProvidesKey;
import com.google.gwt.view.client.SingleSelectionModel;
public class RefreshableSingleSelectionModel<T> extends SingleSelectionModel<T> implements RefreshableSelectionModel<T> {
private EntityIdentityComparator<T> comp;
private final EntityIdentityComparator<T> comp;
public RefreshableSingleSelectionModel() {
super();
@@ -31,14 +31,14 @@ public class RefreshableSingleSelectionModel<T> extends SingleSelectionModel<T>
@Override
public void refreshSelectionModel(Iterable<T> newObjects) {
final Set<T> selectedSet = new HashSet<>(getSelectedSet());
final Set<T> selectedSet = new HashSet<>(getSelectedSet()); // TODO Lukas: a copy doesn't seem required (anymore?) here; the result of getSelectedSet() is not referenced beyond the scope of this method
final T selected = selectedSet.isEmpty() ? null : selectedSet.iterator().next();
clear();
for (final T it : newObjects) {
if (selected != null) {
setSelected(it, comp == null ? selected.equals(it) : comp.representSameEntity(selected, it));
} else {
setSelected(it, false);
setSelected(it, false); // TODO Lukas: clear() already clears the selection
}
}
scheduleSelectionChangeEvent();