Browse Source

added quick workaround for #1980 (IndexedContainer has sluggish equals/hashCode methods)

svn changeset:5181/svn branch:trunk
tags/6.7.0.beta1
Matti Tahvonen 16 years ago
parent
commit
7e2317b6dc
1 changed files with 18 additions and 17 deletions
  1. 18
    17
      src/com/itmill/toolkit/ui/Table.java

+ 18
- 17
src/com/itmill/toolkit/ui/Table.java View File

@@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -43,10 +44,6 @@ import com.itmill.toolkit.terminal.Resource;
* @VERSION@
* @since 3.0
*/
/**
* @author mattitahvonen
*
*/
public class Table extends AbstractSelect implements Action.Container,
Container.Ordered, Container.Sortable {

@@ -232,15 +229,18 @@ public class Table extends AbstractSelect implements Action.Container,
private Object[][] pageBuffer = null;

/**
* List of properties listened - the list is kept to release the listeners
* Set of properties listened - the list is kept to release the listeners
* later.
*
* Note: This should be set or list. IdentityHashMap used due very heavy
* hashCode in indexed container
*/
private LinkedList listenedProperties = null;
private Map listenedProperties = null;

/**
* List of visible components - the is used for needsRepaint calculation.
* Set of visible components - the is used for needsRepaint calculation.
*/
private LinkedList visibleComponents = null;
private HashSet visibleComponents = null;

/**
* List of action handlers.
@@ -1166,12 +1166,12 @@ public class Table extends AbstractSelect implements Action.Container,

if (isContentRefreshesEnabled) {

LinkedList oldListenedProperties = listenedProperties;
LinkedList oldVisibleComponents = visibleComponents;
Map oldListenedProperties = listenedProperties;
HashSet oldVisibleComponents = visibleComponents;

// initialize the listener collections
listenedProperties = new LinkedList();
visibleComponents = new LinkedList();
listenedProperties = new IdentityHashMap();
visibleComponents = new HashSet();

// Collects the basic facts about the table page
final Object[] colids = getVisibleColumns();
@@ -1273,11 +1273,12 @@ public class Table extends AbstractSelect implements Action.Container,
if (p != null || isGenerated) {
if (p instanceof Property.ValueChangeNotifier) {
if (oldListenedProperties == null
|| !oldListenedProperties.contains(p)) {
|| !oldListenedProperties
.containsKey(p)) {
((Property.ValueChangeNotifier) p)
.addListener(this);
}
listenedProperties.add(p);
listenedProperties.put(p, null);
}
if (index < firstIndexNotInCache
&& index >= pageBufferFirstIndex) {
@@ -1348,11 +1349,11 @@ public class Table extends AbstractSelect implements Action.Container,
}

if (oldListenedProperties != null) {
for (final Iterator i = oldListenedProperties.iterator(); i
.hasNext();) {
for (final Iterator i = oldListenedProperties.keySet()
.iterator(); i.hasNext();) {
Property.ValueChangeNotifier o = (ValueChangeNotifier) i
.next();
if (!listenedProperties.contains(o)) {
if (!listenedProperties.containsKey(o)) {
o.removeListener(this);
}
}

Loading…
Cancel
Save