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 5190 Details for
Bug 38782
TreeViewer add calls a refresh
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
log n patch
38782.txt (text/plain), 4.50 KB, created by
Tod Creasey
on 2003-06-13 14:30:01 EDT
(
hide
)
Description:
log n patch
Filename:
MIME Type:
Creator:
Tod Creasey
Created:
2003-06-13 14:30:01 EDT
Size:
4.50 KB
patch
obsolete
>Index: AbstractTreeViewer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java,v >retrieving revision 1.22 >diff -u -r1.22 AbstractTreeViewer.java >--- AbstractTreeViewer.java 11 Jun 2003 18:27:07 -0000 1.22 >+++ AbstractTreeViewer.java 13 Jun 2003 17:34:38 -0000 >@@ -12,13 +12,14 @@ > package org.eclipse.jface.viewers; > > import java.util.ArrayList; >-import java.util.Arrays; > import java.util.HashSet; > import java.util.Iterator; > import java.util.List; > > import org.eclipse.core.runtime.Platform; >- >+import org.eclipse.jface.util.Assert; >+import org.eclipse.jface.util.ListenerList; >+import org.eclipse.jface.util.SafeRunnable; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.BusyIndicator; > import org.eclipse.swt.events.SelectionListener; >@@ -28,10 +29,6 @@ > import org.eclipse.swt.widgets.Item; > import org.eclipse.swt.widgets.Widget; > >-import org.eclipse.jface.util.Assert; >-import org.eclipse.jface.util.ListenerList; >-import org.eclipse.jface.util.SafeRunnable; >- > /** > * Abstract base implementation for tree-structure-oriented viewers > * (trees and table trees). >@@ -102,6 +99,7 @@ > */ > protected AbstractTreeViewer() { > } >+ > /** > * Adds the given child elements to this viewer as children of the given parent element. > * If this viewer does not have a sorter, the elements are added at the end of the >@@ -124,69 +122,51 @@ > if (widget == null) > return; > >- Control tree = getControl(); >- >- // optimization! >- // if the widget is not expanded we just invalidate the subtree >- if (widget instanceof Item) { >- Item ti = (Item) widget; >- if (!getExpanded(ti)) { >- boolean needDummy = isExpandable(parentElement); >- boolean haveDummy = false; >- // remove all children >- Item[] items = getItems(ti); >- for (int i = 0; i < items.length; i++) { >- if (items[i].getData() != null) { >- disassociate(items[i]); >- items[i].dispose(); >- } else { >- if (needDummy && !haveDummy) { >- haveDummy = true; >- } else { >- items[i].dispose(); >- } >- } >- } >- // append a dummy if necessary >- if (needDummy && !haveDummy) { >- newItem(ti, SWT.NULL, -1); >- } else { >- // XXX: Workaround (PR missing) >- tree.redraw(); >- } >- >- return; >- } >+ Object[] filtered = filter(childElements); >+ for (int i = 0; i < filtered.length; i++) { >+ Object element = filtered[i]; >+ int index = indexForElement(widget, element); >+ createTreeItem(widget, filtered[i], index); > } > >- if (childElements.length > 0) { >- List children = Arrays.asList(getSortedChildren(parentElement)); >- for (int cc = 0; cc < childElements.length; cc++) { >- >- int ix = children.indexOf(childElements[cc]); >- if (ix < 0) // child not found: ignore >- continue; >- >- Item[] ch = getChildren(widget); >- if (ch.length + 1 == children.size()) { >- createTreeItem(widget, childElements[cc], ix); >- // insert child at position >- if (ch.length == 0) { >- //System.out.println("WORKAROUND setRedraw"); >- tree.setRedraw(false); // WORKAROUND >- tree.setRedraw(true); // WORKAROUND >+ } /* >+ * Returns the index where the item should be inserted. >+ */ >+ protected int indexForElement(Widget parent, Object element) { >+ ViewerSorter sorter = getSorter(); >+ Item [] items = getChildren(parent); >+ >+ if (sorter == null) >+ return items.length; >+ int count = items.length; >+ int min = 0, max = count - 1; >+ >+ >+ >+ while (min <= max) { >+ int mid = (min + max) / 2; >+ Object data = items[mid].getData(); >+ int compare = sorter.compare(this, data, element); >+ if (compare == 0) { >+ // find first item > element >+ while (compare == 0) { >+ ++mid; >+ if (mid >= count) { >+ break; > } >- continue; >+ data = items[mid].getData(); >+ compare = sorter.compare(this, data, element); > } >- >- // couldn't handle this child: >- // skip other children and do general case >- // call refresh rather than internalRefresh to preserve selection >- refresh(parentElement); >- return; >+ return mid; > } >+ if (compare < 0) >+ min = mid + 1; >+ else >+ max = mid - 1; > } >+ return min; > } >+ > /** > * Adds the given child element to this viewer as a child of the given parent element. > * If this viewer does not have a sorter, the element is added at the end of the
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 38782
:
5165
|
5173
| 5190