Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 378658

Summary: In OperationMode SWT_COMPATIBILITY a new Shell is not created
Product: [RT] RAP Reporter: Johannes Eickhold <jeick>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P1 CC: mpost
Version: 1.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Johannes Eickhold CLA 2012-05-07 08:04:05 EDT
The following example code works as expected in JEE_COMPATIBILITY mode but not in JEE_COMPATIBILITY.

public class Configurator implements ApplicationConfigurator {

  public void configure( ApplicationConfiguration configuration ) {
    configuration.setOperationMode( OperationMode.SWT_COMPATIBILITY );
    configuration.addEntryPoint( "/sd", SimpleDialogSandbox.class, null );
  }
}

public class SimpleDialogSandbox implements IEntryPoint {

  @SuppressWarnings("serial")
  public int createUI() {
    final Display display = new Display();
    final Shell shell = new Shell( display, SWT.NO_TRIM );
    shell.setMaximized( true );
    shell.setLayout( new FillLayout() );

    final Button openDialog = new Button( shell, SWT.PUSH );
    openDialog.setText( "Open Dialog" );
    openDialog.addSelectionListener( new SelectionListener() {

      public void widgetSelected( SelectionEvent e ) {
        int style = SWT.CLOSE;
        Shell dialog = new Shell( display, style );
        dialog.pack();
        dialog.open();
      }

      public void widgetDefaultSelected( SelectionEvent e ) {
        // not used
      }
    } );

    shell.open();
    return 0;
  }
}
Comment 1 Moritz Post CLA 2012-05-07 08:23:59 EDT
In addition to the described behavior, there seams to be a problem with shell resizing too. 

in SWT_COMPAT mode resizing the browser windows does not affect the displayed content.

Eg: starting with a small browser and maximizing leafs the content in the smaller space the browser offered before.

Under JEE_COMPAT the resizing works as expected.
Comment 2 Ivan Furnadjiev CLA 2012-05-07 09:31:10 EDT
All problems are related to the request counter which is *missing* from the JSON meta for some reason.
Comment 3 Ivan Furnadjiev CLA 2012-05-07 09:59:21 EDT
Marked as INVALID as readAndDispatch loop is missing from the snippet.
Comment 4 Johannes Eickhold CLA 2012-05-07 10:03:26 EDT
The correct way to handle events in SWT_COMPATIBILITY mode is to add something like the following snippet to the end of the createUI() method:

  shell.open();

  if( RWT.getLifeCycle() instanceof RWTLifeCycle ) {
    while( !shell.isDisposed() ) {
      if( !display.readAndDispatch() ) {
        display.sleep();
      }
    }
    display.dispose();
  }
  return 0;