Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351585 - Make Dialogs usable from threadless life cycle
Summary: Make Dialogs usable from threadless life cycle
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 1.5 M1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 341761
  Show dependency tree
 
Reported: 2011-07-08 10:56 EDT by Rüdiger Herrmann CLA
Modified: 2011-07-14 09:43 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 Rüdiger Herrmann CLA 2011-07-08 10:56:50 EDT
All subclasses of Dialog that come with RWT run a nested event loop in their open() method. This makes them unusable from applications that use the threadless life cycle (see bug 344091).
A callback should be introduced that notifies the application when the dialog was closed, like the sketch below shows:
  final FontDialog dialog = new FontDialog( parent, SWT.NONE );
  dialog.open( new DialogCallback() {
    public void dialogClosed() {
      applyFont( dialog.getFontList() );
    }
  } );

The challenge here is rather to find a way to provide the extra API that does not (or as least as possible) irritate users of the UI-threaded life cycle but is still as convenient as possible for users of the threadless lifefcyle.
Comment 1 Rüdiger Herrmann CLA 2011-07-14 09:43:25 EDT
Dialog now implements Adaptable. Dialog#getAdapter() returns an IDialogAdapter that can be used to open dialogs in a non-blocking way.

In addition, I created preliminary API for application code to use this feature. org.eclipse.rwt.widgets.DialogUtil#open() can be used to open a given dialog without blocking and a DialogCallback can be supplied to be notified when the dialog was closed.

Alternatively the API could offer an abstract class _NonBlockingDialog_ (or similar) that combines the open() method from DialogUtil with the dialogClosed() callback method from DialogCallback.
abstract class NonBlockingDialog {
  NonBlockingDialog( Dialog dialog ) {
    // ...
  }
  
  void open() {
    // ...
  }
  
  abstract void dialogClosed( int returnCode )
}
application code:
NonBlockingDialog dialog = new NonBlockingDialog( fontDialog ) {
  void dialogClosed( int returnCode ) {
    // ...    
  }
}

What do you think?