Do you use BusyIndicator or setCursor?

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Do you use BusyIndicator or setCursor?

Postby Slot Head » Tue Nov 01, 2005 1:07 pm

There seem to be two ways in SWT that we can change the cursor to an hourglass:
1. Use BusyIndicator.showWhile
2. Use shell.setCursor

This message discusses issues with using either of these approaches and requests feedback on what everyone is using. All responses will be appreciated, TIA. I hope Eric et al don't mind me posting this here- it is a general question and I can't seem to get into the today (and I wish their forum was easy to use like this one)

**Method 1. Use BusyIndicator.showWhile**

The issues I see with using this approach are:
1.1 You have to put the slow code into its own Runnable. While this is arguably correct, it seems pretty inconvenient. For example, we have some slow database hits with subsequent updates to a table. During this time we would like to show the hourglass cursor and disable all GUI. But wait-- since we had put this code into its own thread, that means any updates to the GUI have to be done using display.asyncExec() since this is a different thread than the GUI, right?

The goal of this approach seems to be "if you have really slow code in the GUI thread, you should push it off into its own thread so the GUI will remain responsive." OK, agreed, but a problem we see here is that if you decide to hit a Cancel button in the GUI, you will be doing so with an hourglass cursor. Many, if not most, users probably believe that an hourglass cursor means you can't click on anything. So what we really want is the cursor that combines an arrow with an hourglass. (Us Win32 types are familiar with this, but wonder: do we have this in Macs and Unix systems too?)

**Method 2. Use shell.setCursor**

We tried using this in a large app with deeply nested composites and could not get it to work. So, we wrote a small app to test and of course that worked perfectly the first time. We'll have to figure out what we did wrong.

We do have some questions about this approach. Basically what we are doing here is:
Cursor cursor = new Cursor(display, style);
where style is SWT.CURSOR_WAIT or one of the other SWT.CURSOR_something choices.

The issues we see with this approach are:
2.1 You have to call the dispose method on cursor. I suppose we could always do this when returning to a normal cursor (which we do by passing a null argument to setCursor). But, has anyone done this using some sort of final clean up functionality? Perhaps the finalize method or using phantom references?

2.2 In practice, it seems that when you set the cursor it is for the entire app. Is there anyone out there who wants to set the cursor for, let's say, a subpane in their app which is busy, but still have a normal or arrow/wait cursor for the rest of their app? It seems that to do this, we would have to react to mouse move events in many places and change the cursor as the mouse wanders. That just doesn't seem right.
Slot Head
Posts: 36
Joined: Sun Jul 10, 2005 9:50 am

Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest