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 41233 Details for
Bug 141435
[Viewers] ListViewer without a selection loses scrolled state when refreshed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
JUnit showing the issue
ListViewerRefreshTests.java (text/plain), 3.39 KB, created by
Brad Reynolds
on 2006-05-11 17:06:15 EDT
(
hide
)
Description:
JUnit showing the issue
Filename:
MIME Type:
Creator:
Brad Reynolds
Created:
2006-05-11 17:06:15 EDT
Size:
3.39 KB
patch
obsolete
>import java.util.ArrayList; >import java.util.List; > >import junit.framework.TestCase; > >import org.eclipse.jface.viewers.IStructuredContentProvider; >import org.eclipse.jface.viewers.ListViewer; >import org.eclipse.jface.viewers.StructuredSelection; >import org.eclipse.jface.viewers.Viewer; >import org.eclipse.swt.SWT; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Label; >import org.eclipse.swt.widgets.Shell; > >public class ListViewerRefreshTests extends TestCase { > /** > * Used for viewing the UI. Set to 0 if not wanting to see the UI. > */ > private static final int DELAY = 1000; > private Shell shell = null; > private Label label = null; > private ListViewer viewer = null; > private ArrayList input = null; > > protected void setUp() throws Exception { > shell = new Shell(); > shell.setSize(400, 200); > shell.setLayout(new FillLayout()); > label = new Label(shell, SWT.WRAP); > viewer = new ListViewer(shell); > input = new ArrayList(); > > for (int i = 0; i < 50; i++) { > input.add("item " + i); //$NON-NLS-1$ > } > > viewer.setContentProvider(new ContentProvider()); > viewer.setInput(input); > shell.layout(); > shell.open(); > } > > /** > * Asserts the ability to refresh without a selection and preserve the scrolled to position. > * > * @throws Exception > */ > public void testNoSelectionRefresh() throws Exception { > shell.setText("Lost Scrolled Position Test"); //$NON-NLS-1$ > readAndDispatch(); > > run("Scrolled to position 30.", new Runnable() { //$NON-NLS-1$ > public void run() { > viewer.reveal(input.get(30)); > } > }); > > run("Refreshed viewer without a selection.", new Runnable() { //$NON-NLS-1$ > public void run() { > viewer.refresh(); > } > }); > > //BUG: The top index should not be the first item. > assertTrue(viewer.getList().getTopIndex() != 0); > } > > /** > * Asserts the ability to refresh with a selection and preserve the scrolled to position. > * > * @throws Exception > */ > public void testSelectionRefresh() throws Exception { > shell.setText("Preserved Scrolled Position Test"); //$NON-NLS-1$ > readAndDispatch(); > > run("Setting selection to index 30.", new Runnable() { //$NON-NLS-1$ > public void run() { > viewer.setSelection(new StructuredSelection(input.get(30))); > } > }); > > run("Refreshed viewer with selection.", new Runnable() { //$NON-NLS-1$ > public void run() { > viewer.refresh(); > } > }); > > assertTrue(viewer.getList().getTopIndex() != 0); > } > > /** > * Runs the runnable and displays the description. > * > * @param description > * @param runnable > */ > private void run(String description, Runnable runnable) { > runnable.run(); > label.setText(description); > > readAndDispatch(); > } > > /** > * Flush UI events and {@link #DELAY delays}. > */ > private void readAndDispatch() { > Display display = Display.getCurrent(); > display.readAndDispatch(); > > try { > display.getThread().sleep(DELAY); > } catch (InterruptedException e) { > e.printStackTrace(); > } > } > > private class ContentProvider implements IStructuredContentProvider { > > public Object[] getElements(Object inputElement) { > return ((List) inputElement).toArray(); > } > > public void dispose() { > } > > public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { > } > } >}
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 Raw
Actions:
View
Attachments on
bug 141435
:
41233
|
41406
|
41407
|
50920