View | Details | Raw Unified | Return to bug 141435 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jface/viewers/ListViewer.java (-1 / +15 lines)
Lines 188-192 Link Here
188
    protected void listShowSelection() {
188
    protected void listShowSelection() {
189
        list.showSelection();
189
        list.showSelection();
190
    }
190
    }
191
191
    
192
    /* (non-Javadoc)
193
     * @see org.eclipse.jface.viewers.AbstractListViewer#listGetTopIndex()
194
     */
195
    protected int listGetTopIndex() {
196
    	return list.getTopIndex();
197
    }
198
    
199
    /*
200
     * (non-Javadoc)
201
     * @see org.eclipse.jface.viewers.AbstractListViewer#listSetTopIndex(int)
202
     */
203
    protected void listSetTopIndex(int index) {
204
    	list.setTopIndex(index);
205
    }
192
}
206
}
(-)src/org/eclipse/jface/viewers/AbstractListViewer.java (-3 / +33 lines)
Lines 318-324 Link Here
318
     * Method declared on StructuredViewer.
318
     * Method declared on StructuredViewer.
319
     */
319
     */
320
    protected void internalRefresh(Object element) {
320
    protected void internalRefresh(Object element) {
321
322
        Control list = getControl();
321
        Control list = getControl();
323
        if (element == null || equals(element, getRoot())) {
322
        if (element == null || equals(element, getRoot())) {
324
            // the parent
323
            // the parent
Lines 327-333 Link Here
327
			}
326
			}
328
            unmapAllElements();
327
            unmapAllElements();
329
            List selection = getSelectionFromWidget();
328
            List selection = getSelectionFromWidget();
330
329
            
330
            int topIndex = -1;
331
            if (selection == null || selection.isEmpty()) {
332
            	topIndex = listGetTopIndex();
333
            }
334
            
331
            list.setRedraw(false);
335
            list.setRedraw(false);
332
			listRemoveAll();
336
			listRemoveAll();
333
            
337
            
Lines 345-357 Link Here
345
			
349
			
346
			listSetItems(items);
350
			listSetItems(items);
347
            list.setRedraw(true);
351
            list.setRedraw(true);
348
            setSelectionToWidget(selection, false);
352
            
353
            if (topIndex == -1) {
354
            	setSelectionToWidget(selection, false);
355
            } else {
356
				listSetTopIndex(Math.min(topIndex, children.length));
357
            }
349
        } else {
358
        } else {
350
            doUpdateItem(list, element, true);
359
            doUpdateItem(list, element, true);
351
        }
360
        }
352
    }
361
    }
362
    
363
    /**
364
     * Returns the index of the item currently at the top of the viewable area.
365
     * <p>
366
     * Default implementation returns -1.
367
     * </p>
368
     * @return index, -1 for none
369
     */
370
    protected int listGetTopIndex(){
371
    	return -1;
372
    }
353
373
354
    /**
374
    /**
375
     * Sets the index of the item to be at the top of the viewable area.
376
     * <p>
377
     * Default implementation does nothing.
378
     * </p>
379
     * @param index, -1 for none.  index will always refer to a valid index.
380
     */
381
    protected void listSetTopIndex(int index) {
382
    }
383
    
384
    /**
355
     * Removes the given elements from this list viewer.
385
     * Removes the given elements from this list viewer.
356
     *
386
     *
357
     * @param elements the elements to remove
387
     * @param elements the elements to remove

Return to bug 141435