Browse Source

fixes #5534

svn changeset:14678/svn branch:6.4
tags/6.7.0.beta1
Matti Tahvonen 13 years ago
parent
commit
152c094774

+ 3
- 0
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java View File

@@ -4300,6 +4300,9 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
// still ensure all selects are removed from (not necessary rendered)
selectedRowKeys.clear();
selectedRowRanges.clear();
// also notify server that it clears all previous selections (the client
// side does not know about the invisible ones)
client.updateVariable(paintableId, "clearSelections", true, false);
}

/**

+ 37
- 7
src/com/vaadin/ui/Table.java View File

@@ -1881,37 +1881,67 @@ public class Table extends AbstractSelect implements Action.Container,
final String[] ka = (String[]) variables.get("selected");
final String[] ranges = (String[]) variables.get("selectedRanges");

// Converts the key-array to id-set
final LinkedList s = new LinkedList();
Set<Object> renderedItemIds = getCurrentlyRenderedItemIds();

HashSet<Object> newValue = new HashSet<Object>(
(Collection<Object>) getValue());

if (variables.containsKey("clearSelections")) {
// the client side has instructed to swipe all previous selections
newValue.clear();
} else {
/*
* first clear all selections that are currently rendered rows (the
* ones that the client side counterpart is aware of)
*/
newValue.removeAll(renderedItemIds);
}

/*
* Then add (possibly some of them back) rows that are currently
* selected on the client side (the ones that the client side is aware
* of).
*/
for (int i = 0; i < ka.length; i++) {
// key to id
final Object id = itemIdMapper.get(ka[i]);
if (!isNullSelectionAllowed()
&& (id == null || id == getNullSelectionItemId())) {
// skip empty selection if nullselection is not allowed
requestRepaint();
} else if (id != null && containsId(id)) {
s.add(id);
newValue.add(id);
}
}

if (!isNullSelectionAllowed() && s.size() < 1) {
if (!isNullSelectionAllowed() && newValue.size() < 1) {
// empty selection not allowed, keep old value
requestRepaint();
return;
}

// Add range items
/* Add range items aka shift clicked multiselection areas */
if (ranges != null) {
for (String range : ranges) {
String[] limits = range.split("-");
int start = Integer.valueOf(limits[0]);
int end = Integer.valueOf(limits[1]);
s.addAll(getItemIdsInRange(start, end));
newValue.addAll(getItemIdsInRange(start, end));
}
}

setValue(s, true);
setValue(newValue, true);

}

private Set<Object> getCurrentlyRenderedItemIds() {
HashSet<Object> ids = new HashSet<Object>();
if (pageBuffer != null) {
for (int i = 0; i < pageBuffer[CELL_ITEMID].length; i++) {
ids.add(pageBuffer[CELL_ITEMID][i]);
}
}
return ids;
}

/* Component basics */

Loading…
Cancel
Save