Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 48421 Details for
Bug 154755
[Viewers] Bugs in VIRTUAL support in TableViewer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
patch-154755.txt (text/plain), 4.75 KB, created by
Boris Bokowski
on 2006-08-22 18:02:42 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Boris Bokowski
Created:
2006-08-22 18:02:42 EDT
Size:
4.75 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface >Index: src/org/eclipse/jface/viewers/TableViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java,v >retrieving revision 1.61 >diff -u -r1.61 TableViewer.java >--- src/org/eclipse/jface/viewers/TableViewer.java 17 Aug 2006 19:34:41 -0000 1.61 >+++ src/org/eclipse/jface/viewers/TableViewer.java 22 Aug 2006 22:04:34 -0000 >@@ -13,6 +13,7 @@ > package org.eclipse.jface.viewers; > > import java.util.ArrayList; >+import java.util.Arrays; > import java.util.HashSet; > import java.util.List; > >@@ -143,18 +144,80 @@ > */ > public void notVisibleAdded(Object element, int index) { > >- int requiredCount = index + 1; >+ int requiredCount = getTable().getItemCount() + 1; > >- if (requiredCount > getTable().getItemCount()) { >- getTable().setItemCount(requiredCount); >- Object[] newCache = new Object[requiredCount]; >- System.arraycopy(cachedElements, 0, newCache, 0, >- cachedElements.length); >- cachedElements = newCache; >+ Object[] newCache = new Object[requiredCount]; >+ System.arraycopy(cachedElements, 0, newCache, 0, index); >+ if (index < cachedElements.length) { >+ System.arraycopy(cachedElements, index, newCache, index + 1, cachedElements.length - index); > } >+ newCache[index] = element; >+ cachedElements = newCache; > >- cachedElements[index] = element; >+ getTable().setItemCount(requiredCount); >+ } >+ >+ /** >+ * The elements with the given indices need to be removed from the cache. >+ * @param indices >+ */ >+ public void removeIndices(int[] indices) { >+ if (indices.length==1) { >+ removeIndicesFromTo(indices[0], indices[0]); >+ } >+ int requiredCount = getTable().getItemCount() - indices.length; >+ >+ Arrays.sort(indices); >+ Object[] newCache = new Object[requiredCount]; >+ int indexInNewCache = 0; >+ int nextToSkip = 0; >+ for (int i=0; i<cachedElements.length; i++) { >+ if (nextToSkip < indices.length && i == indices[nextToSkip]) { >+ nextToSkip++; >+ } else { >+ newCache[indexInNewCache++] = cachedElements[i]; >+ } >+ } >+ cachedElements = newCache; >+ } >+ >+ /** >+ * The elements between the given indices (inclusive) need to be removed from the cache. >+ * @param from >+ * @param to >+ */ >+ public void removeIndicesFromTo(int from, int to) { >+ int indexAfterTo = to + 1; >+ Object[] newCache = new Object[cachedElements.length - (indexAfterTo - from)]; >+ System.arraycopy(cachedElements, 0, newCache, 0, from); >+ if (indexAfterTo < cachedElements.length) { >+ System.arraycopy(cachedElements, indexAfterTo, newCache, from, cachedElements.length - indexAfterTo); >+ } >+ } >+ >+ /** >+ * @param element >+ * @return the index of the element in the cache, or null >+ */ >+ public int find(Object element) { >+ return Arrays.asList(cachedElements).indexOf(element); >+ } > >+ /** >+ * @param count >+ */ >+ public void adjustCacheSize(int count) { >+ if (count == cachedElements.length) { >+ return; >+ } else if (count < cachedElements.length) { >+ Object[] newCache = new Object[count]; >+ System.arraycopy(cachedElements, 0, newCache, 0, count); >+ cachedElements = newCache; >+ } else { >+ Object[] newCache = new Object[count]; >+ System.arraycopy(cachedElements, 0, newCache, 0, cachedElements.length); >+ cachedElements = newCache; >+ } > } > > } >@@ -814,6 +877,9 @@ > > disassociate(items[i]); > } >+ if (virtualManager != null) { >+ virtualManager.removeIndicesFromTo(min, items.length - 1); >+ } > table.remove(min, items.length - 1); > } > // Workaround for 1GDGN4Q: ITPUI:WIN2000 - TableViewer icons get >@@ -855,7 +921,12 @@ > int count = 0; > for (int i = 0; i < elements.length; ++i) { > Widget w = findItem(elements[i]); >- if (w instanceof TableItem) { >+ if (w == null && virtualManager != null) { >+ int index = virtualManager.find(elements[i]); >+ if (index != -1) { >+ indices[count++] = index; >+ } >+ } else if (w instanceof TableItem) { > TableItem item = (TableItem) w; > disassociate(item); > indices[count++] = table.indexOf(item); >@@ -864,6 +935,9 @@ > if (count < indices.length) { > System.arraycopy(indices, 0, indices = new int[count], 0, count); > } >+ if (virtualManager != null) { >+ virtualManager.removeIndices(indices); >+ } > table.remove(indices); > > // Workaround for 1GDGN4Q: ITPUI:WIN2000 - TableViewer icons get >@@ -1171,6 +1245,9 @@ > */ > public void setItemCount(int count) { > getTable().setItemCount(count); >+ if (virtualManager != null) { >+ virtualManager.adjustCacheSize(count); >+ } > getTable().redraw(); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 154755
: 48421