Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 4760 - BusyIndicator does not work when setCursor is used for widget (1GGZ25W)
Summary: BusyIndicator does not work when setCursor is used for widget (1GGZ25W)
Status: RESOLVED DUPLICATE of bug 6325
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: All Windows All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 16783 18247 19760 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-10-11 14:22 EDT by Lynne Kues CLA
Modified: 2002-07-10 18:45 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lynne Kues CLA 2001-10-11 14:22:32 EDT
1.  Import and run the test class below.
2.  Execute menu item Test-->Run Test 1.  Keep cursor in the window.
	 Notice that a busy cursor is displayed.
3.  Execute menu item Test-->Run Test 2.  Keep cursor in the window.
	 Notice that a busy cursor is NOT displayed.  If you use the setCursor API, 
	 BusyIndicator.showWhile no longer works for some reason.

import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

/**
*/
public class TestViewer implements DisposeListener{  
	Shell shell;
	Cursor ibeamCursor = null;
	Composite widget;
public static void main (String [] args) {
	TestViewer example = new TestViewer ();
	example.open ();
	example.run ();
	example.close ();
}
public void close () {
	if (shell != null && !shell.isDisposed ()) 
		shell.dispose ();
}
void createMenuBar () {
	Menu bar = new Menu (shell, SWT.BAR);
	shell.setMenuBar (bar);

	MenuItem item = new MenuItem (bar, SWT.CASCADE);
	item.setText ("Test");
	item.setMenu (createTestMenu ());

}
void createShell () {
	shell = new Shell ();
	shell.setText ("Test");	
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	shell.setSize(500, 400);
	shell.setLayout(layout);
}
Menu createTestMenu() {
	Menu bar = shell.getMenuBar ();
	Menu menu = new Menu (bar);
	MenuItem item;

	item = new MenuItem (menu, SWT.CASCADE);
	item.setText ("Run Test 1");
	item.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent event) {
			runTest1();
		}
	});
	item = new MenuItem (menu, SWT.CASCADE);
	item.setText ("Run Test 2");
	item.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent event) {
			runTest2();
		}
	});

	return menu;
}
void createComposite() {
	widget = new Composite (shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
	GridData spec = new GridData();
	spec.horizontalAlignment = spec.FILL;
	spec.grabExcessHorizontalSpace = true;
	spec.verticalAlignment = spec.FILL;
	spec.grabExcessVerticalSpace = true;
	widget.setLayoutData(spec);
}
void runTest2() {
	ibeamCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_IBEAM);
	widget.setCursor(ibeamCursor);
	Runnable r = new Runnable() {
		public void run() {
			try {
				Thread.sleep(3000);
			} catch (Exception e) {}
		}
	};
	BusyIndicator.showWhile(shell.getDisplay(), r);
}
void runTest1() {
	widget.setCursor(null);
	Runnable r = new Runnable() {
		public void run() {
			try {
				Thread.sleep(3000);
			} catch (Exception e) {}
		}
	};
	BusyIndicator.showWhile(shell.getDisplay(), r);
}
public void open () {
	createShell ();
	createMenuBar ();
	createComposite ();
	shell.open ();
}
public void run () {
	Display display = shell.getDisplay ();
	while (!shell.isDisposed ())
		if (!display.readAndDispatch ()) display.sleep ();
}
public void widgetDisposed (DisposeEvent event) {
	if (ibeamCursor != null) ibeamCursor.dispose();
}
}

NOTES:

LK (7/16/01 3:49:50 PM)
	This is why StyledText does not display a busy cursor properly.  See:
		 PR 1GEK10Y: SWT:WIN2000 - StyledText - No busy cursor

McQ (17/07/2001 9:03:44 AM) -
	I find that surprising, since I see an "i beam" cursor when I'm over the widget. 
	Prsesumably, you are setting this cursor.

LK (7/17/01 10:16:48 AM)
	Yes we are setting the cursor, but why should that matter?  Shouldn't BusyIndicator.showWhile work regardless of 
	what the cursor may be at the time?  Maybe I don't understand the rules about using the BusyIndicator.
Comment 1 Lynne Kues CLA 2001-10-16 14:01:51 EDT
Need to get SN to look at this.
Comment 2 DJ Houghton CLA 2001-10-29 16:36:19 EST
PRODUCT VERSION:
0.125

Comment 3 Mike Wilson CLA 2002-05-22 10:17:23 EDT
SN should comment on the situation in this PR or one of the duplicate 
versions of it. Also, please search for all duplicates and link them 
together.
Comment 4 Mike Wilson CLA 2002-05-22 10:17:53 EDT
*** Bug 16783 has been marked as a duplicate of this bug. ***
Comment 5 Christophe Cornu CLA 2002-06-10 11:35:09 EDT
*** Bug 19760 has been marked as a duplicate of this bug. ***
Comment 6 Christophe Cornu CLA 2002-06-10 12:06:17 EDT
*** Bug 18247 has been marked as a duplicate of this bug. ***
Comment 7 Steve Northover CLA 2002-07-10 18:45:30 EDT

*** This bug has been marked as a duplicate of 6325 ***