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 282551 Details for
Bug 562463
[GTK] No spinning/busy cursor is seen in BusyIndicator.showWhile()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
A simple example to test
BusyIndicatorIssue.java (text/x-java), 3.38 KB, created by
Oleksandr Mytrofanov
on 2020-04-24 08:04:13 EDT
(
hide
)
Description:
A simple example to test
Filename:
MIME Type:
Creator:
Oleksandr Mytrofanov
Created:
2020-04-24 08:04:13 EDT
Size:
3.38 KB
patch
obsolete
>import org.eclipse.swt.SWT; >import org.eclipse.swt.custom.BusyIndicator; >import org.eclipse.swt.graphics.Cursor; >import org.eclipse.swt.layout.RowLayout; >import org.eclipse.swt.widgets.*; > >public class BusyIndicatorIssue { > > // start copy-past from original BussyIndicator class > static int nextBusyId = 1; > static final String BUSYID_NAME = "SWT BusyIndicator"; //$NON-NLS-1$ > static final String BUSY_CURSOR = "SWT BusyIndicator Cursor"; //$NON-NLS-1$ > // end copy-past from original BussyIndicator class > > private static class Task implements Runnable { > > private String description; > > Task(String description){ > this.description = description; > } > > @Override > public void run() { > System.out.printf("A task %s has started\n", description); > for (int i = 0; i < 40; i++) { > try { > Thread.sleep(100); > } catch (InterruptedException e) { > e.printStackTrace(); > } > } > System.out.printf("A task %s has ended\n", description); > > } > }; > > public static void main (String [] args) { > Display display = new Display(); > Shell shell = new Shell(display); > shell.setLayout(new RowLayout(SWT.HORIZONTAL)); > Button b1 = new Button(shell, SWT.NONE); > b1.setText("Run task with default BusyIndicator..."); > b1.addListener(SWT.Selection, new Listener() { > @Override > public void handleEvent(Event event){ > BusyIndicator.showWhile(display, new Task("without a spinning cursor")); > } > }); > Button b2 = new Button(shell, SWT.NONE); > b2.setText("Run task with updated BusyIndicator..."); > b2.addListener(SWT.Selection, new Listener() { > @Override > public void handleEvent(Event event){ > showWhile(display, new Task("with a spinning cursor")); > } > }); > shell.pack(); > shell.open (); > while (!shell.isDisposed ()) { > if (!display.readAndDispatch ()) display.sleep (); > } > shell.dispose(); > display.dispose (); > } > > // start copy-past from BussyIndicator class > > public static void showWhile(Display display, Runnable runnable) { > if (runnable == null) > SWT.error(SWT.ERROR_NULL_ARGUMENT); > if (display == null) { > display = Display.getCurrent(); > if (display == null) { > runnable.run(); > return; > } > } > > Integer busyId = Integer.valueOf(nextBusyId); > nextBusyId++; > Cursor cursor = display.getSystemCursor(SWT.CURSOR_WAIT); > Shell[] shells = display.getShells(); > for (Shell shell : shells) { > Integer id = (Integer)shell.getData(BUSYID_NAME); > if (id == null) { > setCursorAndId(shell, cursor, busyId); > } > } > > try { > runnable.run(); > } finally { > shells = display.getShells(); > for (Shell shell : shells) { > Integer id = (Integer)shell.getData(BUSYID_NAME); > if (id == busyId) { > setCursorAndId(shell, null, null); > } > } > } > } > > /** > * Paranoia code to make sure we don't break UI because of one shell disposed, see bug 532632 comment 20 > */ > private static void setCursorAndId(Shell shell, Cursor cursor, Integer busyId) { > if (!shell.isDisposed()) { > shell.setCursor(cursor); > // change: Additional Explicit update ! > shell.update(); > // end change > } > if (!shell.isDisposed()) { > shell.setData(BUSYID_NAME, busyId); > } > } > > // end copy-past from BussyIndicator class >}
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 562463
: 282551