Bug 392848 - Scrollbar can malfunction if layout happens during scroll
Summary: Scrollbar can malfunction if layout happens during scroll
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.8   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-25 12:32 EDT by Adam Briska CLA
Modified: 2012-10-25 12:33 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Briska CLA 2012-10-25 12:32:37 EDT
package com.dnastar.common.ui.draw2d;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import org.eclipse.draw2d.GridData;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.ScrollBar;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


public class Bug extends Composite {
	private static final int VALUE = 0;
	private static final int EXTENT = 1;
	private static final int MIN = 0;
	private static final int MAX = 100;
	
	private ScrollBar m_scroll;

	public Bug(Composite parent, int style) {
		super(parent, style);
		setLayout(new FillLayout());
		

		Canvas canvas = new Canvas(this, SWT.NONE);
		
		final LightweightSystem m_lws = new LightweightSystem();
		m_lws.setControl(canvas);

		final RectangleFigure top = new RectangleFigure();
		top.setLayoutManager(new GridLayout(2, false));
		m_lws.setContents(top);
		
		m_scroll = new ScrollBar();
		m_scroll.setHorizontal(true);
		m_scroll.setMaximum(MAX);
		m_scroll.setMinimum(MIN);
		m_scroll.setPageIncrement(1);
		m_scroll.setExtent(EXTENT);
		m_scroll.setValue(VALUE);

		top.add(m_scroll);
		top.setConstraint(m_scroll, new GridData(SWT.FILL, SWT.FILL, true, false));

		m_scroll.getRangeModel().addPropertyChangeListener(new PropertyChangeListener() {
			@Override
			public void propertyChange(PropertyChangeEvent arg0) {
				m_scroll.invalidate();
				m_lws.getUpdateManager().performUpdate();
			}
		});

	}


	public static void main(String[] args) {
		Display display = new Display ();

		Shell shell = new Shell (display);
		shell.setLayout (new FillLayout ());

		new Bug(shell, SWT.NONE);

		shell.pack();
		shell.open ();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
	}

}
Comment 1 Adam Briska CLA 2012-10-25 12:33:44 EDT
This is very similar to bug 17760.  If I repeatedly click around the thumb, I can get the scroll bar to scroll uncontrollably off to one side.