Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] Interesting threading example...

Found the following quick example of starting something in a thread, showing the busy cursor (for the ui element that is waiting on the result) and updating the status on error....

        // Start busy indicator.
BusyIndicator.showWhile(parentWizardPage.getShell().getDisplay(), new Runnable() {
            public void run() {
                Platform.run(new SafeRunnable() {

                    /**
                     * Add the exception details to status is one happens.
                     */
                    public void handleException(Throwable e) {
                        statuses[0] =
                            new Status(
                                IStatus.ERROR,
                                wizardElement
                                    .getConfigurationElement()
                                    .getDeclaringExtension()
                                    .getUniqueIdentifier(),
                                IStatus.OK,
e.getMessage() == null ? "" : e.getMessage(), //$NON-NLS-1$,
                                e);
                    }
                    public void run() {
                        try {
                            workbenchWizard[0] = createWizard();
                            // create instance of target wizard
                        } catch (CoreException e) {
                            statuses[0] = e.getStatus();
                        }
                    }
                });
            }
        });




Back to the top