Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 370139
Collapse All | Expand All

(-)js/org/eclipse/swt/widgets/ShellAdapter.js (-1 / +7 lines)
Lines 22-28 Link Here
22
        result.setParentShell( parentShell );    
22
        result.setParentShell( parentShell );    
23
      }
23
      }
24
      result.initialize();
24
      result.initialize();
25
      result.show();
26
    } );
25
    } );
27
    return result;
26
    return result;
28
  },
27
  },
Lines 40-45 Link Here
40
    "image",
39
    "image",
41
    "text",
40
    "text",
42
    "alpha",
41
    "alpha",
42
    // Important: Order matters: opened, active, mode
43
    "opened",
43
    "active",
44
    "active",
44
    "mode",
45
    "mode",
45
    "hasShellListener",
46
    "hasShellListener",
Lines 71-76 Link Here
71
        shell.setActiveControl( widget );
72
        shell.setActiveControl( widget );
72
      } );
73
      } );
73
    },
74
    },
75
    "opened" : function( shell, value ) {
76
      if( value ) {
77
        shell.open();
78
      }
79
    },
74
    "mode" : function( shell, value ) {
80
    "mode" : function( shell, value ) {
75
      var fullscreen = value === "fullscreen";
81
      var fullscreen = value === "fullscreen";
76
      shell.setMode( fullscreen ? "maximized" : value );
82
      shell.setMode( fullscreen ? "maximized" : value );
(-)widgetkits/org/eclipse/swt/internal/widgets/shellkit/ShellLCA.java (+11 lines)
Lines 118-123 Link Here
118
    renderImage( shell );
118
    renderImage( shell );
119
    renderText( shell );
119
    renderText( shell );
120
    renderAlpha( shell );
120
    renderAlpha( shell );
121
    renderOpen( shell );
121
    renderActiveShell( shell );
122
    renderActiveShell( shell );
122
    // Important: Order matters, write setMode() after open() and before
123
    // Important: Order matters, write setMode() after open() and before
123
    // setBounds() - see bug 302224
124
    // setBounds() - see bug 302224
Lines 169-174 Link Here
169
  /////////////////////////////////////////////
170
  /////////////////////////////////////////////
170
  // Methods to read and write the active shell
171
  // Methods to read and write the active shell
171
172
173
  private static void renderOpen( Shell shell ) {
174
    Boolean newValue = Boolean.valueOf( shell.getVisible() );
175
    Boolean defValue = Boolean.FALSE;
176
    String prop = Props.VISIBLE;
177
    if( WidgetLCAUtil.hasChanged( shell, prop, newValue, defValue ) && shell.getVisible() ) {
178
      IClientObject clientObject = ClientObjectFactory.getForWidget( shell );
179
      clientObject.set( "opened", true );
180
    }
181
  }
182
172
  private static void renderActiveShell( Shell shell ) {
183
  private static void renderActiveShell( Shell shell ) {
173
    Shell activeShell = shell.getDisplay().getActiveShell();
184
    Shell activeShell = shell.getDisplay().getActiveShell();
174
    boolean hasChanged = WidgetLCAUtil.hasChanged( shell, PROP_ACTIVE_SHELL, activeShell, null );
185
    boolean hasChanged = WidgetLCAUtil.hasChanged( shell, PROP_ACTIVE_SHELL, activeShell, null );
(-)js/org/eclipse/rwt/test/fixture/TestUtil.js (-1 / +2 lines)
Lines 893-899 Link Here
893
      "action" : "create",
893
      "action" : "create",
894
      "type" : "rwt.widgets.Shell",
894
      "type" : "rwt.widgets.Shell",
895
      "properties" : {
895
      "properties" : {
896
        "style" : [ "BORDER" ]
896
        "style" : [ "BORDER" ],
897
        "opened" : true
897
      }
898
      }
898
    } );
899
    } );
899
    return org.eclipse.rwt.protocol.ObjectManager.getObject( id );
900
    return org.eclipse.rwt.protocol.ObjectManager.getObject( id );
(-)js/org/eclipse/rwt/test/tests/ShellProtocolIntegrationTest.js (-2 / +12 lines)
Lines 42-48 Link Here
42
      assertTrue( shell._onTop );
42
      assertTrue( shell._onTop );
43
      assertTrue( shell._appModal );
43
      assertTrue( shell._appModal );
44
      org.eclipse.rwt.test.fixture.TestUtil.flush();
44
      org.eclipse.rwt.test.fixture.TestUtil.flush();
45
      assertTrue( shell.isSeeable() );
45
      assertFalse( shell.isSeeable() );
46
      this._disposeShell();
46
      this._disposeShell();
47
    },
47
    },
48
48
Lines 82-87 Link Here
82
      this._disposeShell();
82
      this._disposeShell();
83
    },
83
    },
84
84
85
    testSetOpened : function() {
86
      var shell = this._protocolCreateShell();
87
      this._protocolSet( { "opened" : true } );
88
      org.eclipse.rwt.test.fixture.TestUtil.flush();
89
      assertTrue( shell.isSeeable() );
90
      this._disposeShell();
91
    },
92
85
    testSetActive : function() {
93
    testSetActive : function() {
86
      var shell = this._protocolCreateShell();
94
      var shell = this._protocolCreateShell();
87
      this._protocolSet( { "active" : true } );
95
      this._protocolSet( { "active" : true } );
Lines 225-234 Link Here
225
    // See Bug 354912 - New Shell opens in background, not visible 
233
    // See Bug 354912 - New Shell opens in background, not visible 
226
    testSetParentShellZIndex : function() {
234
    testSetParentShellZIndex : function() {
227
      var parent = this._protocolCreateShell( "wParent" );
235
      var parent = this._protocolCreateShell( "wParent" );
236
      parent.open();
228
      parent.setActive( true ); // otherwise it would not be automatically in front
237
      parent.setActive( true ); // otherwise it would not be automatically in front
229
      org.eclipse.rwt.test.fixture.TestUtil.flush();      
238
      org.eclipse.rwt.test.fixture.TestUtil.flush();
230
239
231
      var shell = this._protocolCreateShell( "w3", "wParent" );
240
      var shell = this._protocolCreateShell( "w3", "wParent" );
241
      shell.open();
232
      
242
      
233
      org.eclipse.rwt.test.fixture.TestUtil.flush();      
243
      org.eclipse.rwt.test.fixture.TestUtil.flush();      
234
      assertTrue( shell.getZIndex() > parent.getZIndex() );
244
      assertTrue( shell.getZIndex() > parent.getZIndex() );
(-)src/org/eclipse/swt/internal/widgets/shellkit/ShellLCA_Test.java (-30 / +30 lines)
Lines 38-49 Link Here
38
38
39
  private Display display;
39
  private Display display;
40
  private Shell shell;
40
  private Shell shell;
41
  private ShellLCA lca;
41
42
42
  @Override
43
  @Override
43
  protected void setUp() throws Exception {
44
  protected void setUp() throws Exception {
44
    Fixture.setUp();
45
    Fixture.setUp();
45
    display = new Display();
46
    display = new Display();
46
    shell = new Shell( display );
47
    shell = new Shell( display );
48
    lca = new ShellLCA();
47
    Fixture.fakeNewRequest( display );
49
    Fixture.fakeNewRequest( display );
48
  }
50
  }
49
51
Lines 350-356 Link Here
350
352
351
  public void testAlpha() throws Exception {
353
  public void testAlpha() throws Exception {
352
    shell.open();
354
    shell.open();
353
    ShellLCA lca = new ShellLCA();
354
355
355
    shell.setAlpha( 23 );
356
    shell.setAlpha( 23 );
356
    lca.renderChanges( shell );
357
    lca.renderChanges( shell );
Lines 361-367 Link Here
361
362
362
  public void testRenderMode() throws Exception {
363
  public void testRenderMode() throws Exception {
363
    shell.open();
364
    shell.open();
364
    ShellLCA lca = new ShellLCA();
365
365
366
    shell.setMaximized( true );
366
    shell.setMaximized( true );
367
    lca.renderChanges( shell );
367
    lca.renderChanges( shell );
Lines 374-380 Link Here
374
    Fixture.markInitialized( display );
374
    Fixture.markInitialized( display );
375
    Fixture.markInitialized( shell );
375
    Fixture.markInitialized( shell );
376
    shell.open();
376
    shell.open();
377
    ShellLCA lca = new ShellLCA();
378
    shell.setFullScreen( true );
377
    shell.setFullScreen( true );
379
    Fixture.preserveWidgets();
378
    Fixture.preserveWidgets();
380
379
Lines 387-393 Link Here
387
386
388
  public void testResetFullscreen() throws Exception {
387
  public void testResetFullscreen() throws Exception {
389
    shell.open();
388
    shell.open();
390
    ShellLCA lca = new ShellLCA();
391
389
392
    shell.setFullScreen( true );
390
    shell.setFullScreen( true );
393
    lca.renderChanges( shell );
391
    lca.renderChanges( shell );
Lines 397-404 Link Here
397
  }
395
  }
398
396
399
  public void testRenderDefaultButtonIntiallyNull() throws IOException {
397
  public void testRenderDefaultButtonIntiallyNull() throws IOException {
400
    ShellLCA lca = new ShellLCA();
401
402
    lca.renderChanges( shell );
398
    lca.renderChanges( shell );
403
399
404
    Message message = Fixture.getProtocolMessage();
400
    Message message = Fixture.getProtocolMessage();
Lines 406-412 Link Here
406
  }
402
  }
407
403
408
  public void testRenderDefaultButtonInitiallySet() throws Exception {
404
  public void testRenderDefaultButtonInitiallySet() throws Exception {
409
    ShellLCA lca = new ShellLCA();
410
    Button button = new Button( shell, SWT.PUSH );
405
    Button button = new Button( shell, SWT.PUSH );
411
406
412
    shell.setDefaultButton( button );
407
    shell.setDefaultButton( button );
Lines 419-425 Link Here
419
  public void testRenderDefaultButtonUnchanged() throws IOException {
414
  public void testRenderDefaultButtonUnchanged() throws IOException {
420
    Fixture.markInitialized( display );
415
    Fixture.markInitialized( display );
421
    Fixture.markInitialized( shell );
416
    Fixture.markInitialized( shell );
422
    ShellLCA lca = new ShellLCA();
423
    shell.setDefaultButton( new Button( shell, SWT.PUSH ) );
417
    shell.setDefaultButton( new Button( shell, SWT.PUSH ) );
424
418
425
    Fixture.preserveWidgets();
419
    Fixture.preserveWidgets();
Lines 432-438 Link Here
432
  public void testResetDefaultButton() throws IOException {
426
  public void testResetDefaultButton() throws IOException {
433
    Fixture.markInitialized( display );
427
    Fixture.markInitialized( display );
434
    Fixture.markInitialized( shell );
428
    Fixture.markInitialized( shell );
435
    ShellLCA lca = new ShellLCA();
436
    Button button = new Button( shell, SWT.PUSH );
429
    Button button = new Button( shell, SWT.PUSH );
437
    shell.setDefaultButton( button );
430
    shell.setDefaultButton( button );
438
    Fixture.preserveWidgets();
431
    Fixture.preserveWidgets();
Lines 445-452 Link Here
445
  }
438
  }
446
439
447
  public void testRenderActiveControlIntiallyNull() throws IOException {
440
  public void testRenderActiveControlIntiallyNull() throws IOException {
448
    ShellLCA lca = new ShellLCA();
449
450
    lca.renderChanges( shell );
441
    lca.renderChanges( shell );
451
442
452
    Message message = Fixture.getProtocolMessage();
443
    Message message = Fixture.getProtocolMessage();
Lines 454-460 Link Here
454
  }
445
  }
455
446
456
  public void testRenderActiveControlInitiallySet() throws Exception {
447
  public void testRenderActiveControlInitiallySet() throws Exception {
457
    ShellLCA lca = new ShellLCA();
458
    Button button = new Button( shell, SWT.PUSH );
448
    Button button = new Button( shell, SWT.PUSH );
459
    IShellAdapter adapter = shell.getAdapter( IShellAdapter.class );
449
    IShellAdapter adapter = shell.getAdapter( IShellAdapter.class );
460
450
Lines 471-477 Link Here
471
    Button button = new Button( shell, SWT.PUSH );
461
    Button button = new Button( shell, SWT.PUSH );
472
    IShellAdapter adapter = shell.getAdapter( IShellAdapter.class );
462
    IShellAdapter adapter = shell.getAdapter( IShellAdapter.class );
473
    adapter.setActiveControl( button );
463
    adapter.setActiveControl( button );
474
    ShellLCA lca = new ShellLCA();
475
464
476
    Fixture.preserveWidgets();
465
    Fixture.preserveWidgets();
477
    lca.renderChanges( shell );
466
    lca.renderChanges( shell );
Lines 486-492 Link Here
486
    Button button = new Button( shell, SWT.PUSH );
475
    Button button = new Button( shell, SWT.PUSH );
487
    IShellAdapter adapter = shell.getAdapter( IShellAdapter.class );
476
    IShellAdapter adapter = shell.getAdapter( IShellAdapter.class );
488
    adapter.setActiveControl( button );
477
    adapter.setActiveControl( button );
489
    ShellLCA lca = new ShellLCA();
490
    Fixture.preserveWidgets();
478
    Fixture.preserveWidgets();
491
479
492
    adapter.setActiveControl( null );
480
    adapter.setActiveControl( null );
Lines 509-515 Link Here
509
    Fixture.markInitialized( display );
497
    Fixture.markInitialized( display );
510
    Fixture.preserveWidgets();
498
    Fixture.preserveWidgets();
511
    shell.setMinimumSize( 100, 200 );
499
    shell.setMinimumSize( 100, 200 );
512
    ShellLCA lca = new ShellLCA();
513
500
514
    lca.renderChanges( shell );
501
    lca.renderChanges( shell );
515
502
Lines 521-527 Link Here
521
    Shell shell = new Shell( display , SWT.NO_TRIM );
508
    Shell shell = new Shell( display , SWT.NO_TRIM );
522
    Fixture.markInitialized( display );
509
    Fixture.markInitialized( display );
523
    Fixture.preserveWidgets();
510
    Fixture.preserveWidgets();
524
    ShellLCA lca = new ShellLCA();
525
511
526
    lca.renderInitialization( shell );
512
    lca.renderInitialization( shell );
527
513
Lines 536-542 Link Here
536
    Fixture.markInitialized( display );
522
    Fixture.markInitialized( display );
537
    Fixture.markInitialized( shell );
523
    Fixture.markInitialized( shell );
538
    Fixture.preserveWidgets();
524
    Fixture.preserveWidgets();
539
    ShellLCA lca = new ShellLCA();
540
525
541
    shell.setText( "foo" );
526
    shell.setText( "foo" );
542
    lca.renderChanges( shell );
527
    lca.renderChanges( shell );
Lines 550-556 Link Here
550
    Fixture.markInitialized( display );
535
    Fixture.markInitialized( display );
551
    Fixture.markInitialized( shell );
536
    Fixture.markInitialized( shell );
552
    Fixture.preserveWidgets();
537
    Fixture.preserveWidgets();
553
    ShellLCA lca = new ShellLCA();
554
538
555
    shell.addShellListener( new ShellAdapter(){ } );
539
    shell.addShellListener( new ShellAdapter(){ } );
556
    lca.renderChanges( shell );
540
    lca.renderChanges( shell );
Lines 564-570 Link Here
564
    Fixture.markInitialized( display );
548
    Fixture.markInitialized( display );
565
    Fixture.markInitialized( shell );
549
    Fixture.markInitialized( shell );
566
    shell.addShellListener( new ShellAdapter(){ } );
550
    shell.addShellListener( new ShellAdapter(){ } );
567
    ShellLCA lca = new ShellLCA();
568
551
569
    Fixture.preserveWidgets();
552
    Fixture.preserveWidgets();
570
    lca.renderChanges( shell );
553
    lca.renderChanges( shell );
Lines 575-581 Link Here
575
558
576
  public void testRenderRemoveShellListener() throws Exception {
559
  public void testRenderRemoveShellListener() throws Exception {
577
    Shell shell = new Shell( display , SWT.SHELL_TRIM );
560
    Shell shell = new Shell( display , SWT.SHELL_TRIM );
578
    ShellLCA lca = new ShellLCA();
579
    Fixture.markInitialized( display );
561
    Fixture.markInitialized( display );
580
    Fixture.markInitialized( shell );
562
    Fixture.markInitialized( shell );
581
    ShellListener listener = new ShellAdapter(){};
563
    ShellListener listener = new ShellAdapter(){};
Lines 594-600 Link Here
594
    shell.open();
576
    shell.open();
595
    Fixture.markInitialized( display );
577
    Fixture.markInitialized( display );
596
    Fixture.preserveWidgets();
578
    Fixture.preserveWidgets();
597
    ShellLCA lca = new ShellLCA();
598
579
599
    shell.setActive();
580
    shell.setActive();
600
    assertTrue( shell.getDisplay().getActiveShell() == shell );
581
    assertTrue( shell.getDisplay().getActiveShell() == shell );
Lines 610-616 Link Here
610
    Fixture.markInitialized( display );
591
    Fixture.markInitialized( display );
611
    Fixture.markInitialized( parentShell );
592
    Fixture.markInitialized( parentShell );
612
    Fixture.preserveWidgets();
593
    Fixture.preserveWidgets();
613
    ShellLCA lca = new ShellLCA();
614
594
615
    lca.renderInitialization( dialogShell );
595
    lca.renderInitialization( dialogShell );
616
596
Lines 624-630 Link Here
624
    Fixture.markInitialized( display );
604
    Fixture.markInitialized( display );
625
    Fixture.markInitialized( shell );
605
    Fixture.markInitialized( shell );
626
    Fixture.preserveWidgets();
606
    Fixture.preserveWidgets();
627
    ShellLCA lca = new ShellLCA();
628
607
629
    shell.setImage( Graphics.getImage( Fixture.IMAGE1 ) );
608
    shell.setImage( Graphics.getImage( Fixture.IMAGE1 ) );
630
    lca.renderChanges( shell );
609
    lca.renderChanges( shell );
Lines 639-645 Link Here
639
    Fixture.markInitialized( display );
618
    Fixture.markInitialized( display );
640
    Fixture.markInitialized( shell );
619
    Fixture.markInitialized( shell );
641
    Fixture.preserveWidgets();
620
    Fixture.preserveWidgets();
642
    ShellLCA lca = new ShellLCA();
643
621
644
    shell.setImage( Graphics.getImage( Fixture.IMAGE1 ) );
622
    shell.setImage( Graphics.getImage( Fixture.IMAGE1 ) );
645
    lca.renderChanges( shell );
623
    lca.renderChanges( shell );
Lines 653-659 Link Here
653
    Fixture.markInitialized( display );
631
    Fixture.markInitialized( display );
654
    Fixture.markInitialized( shell );
632
    Fixture.markInitialized( shell );
655
    Fixture.preserveWidgets();
633
    Fixture.preserveWidgets();
656
    ShellLCA lca = new ShellLCA();
657
634
658
    shell.setImage( Graphics.getImage( Fixture.IMAGE1 ) );
635
    shell.setImage( Graphics.getImage( Fixture.IMAGE1 ) );
659
    lca.renderChanges( shell );
636
    lca.renderChanges( shell );
Lines 668-674 Link Here
668
    Fixture.markInitialized( display );
645
    Fixture.markInitialized( display );
669
    Fixture.markInitialized( shell );
646
    Fixture.markInitialized( shell );
670
    Fixture.preserveWidgets();
647
    Fixture.preserveWidgets();
671
    ShellLCA lca = new ShellLCA();
672
648
673
    shell.setImages( new Image[] { Graphics.getImage( Fixture.IMAGE1 ) } );
649
    shell.setImages( new Image[] { Graphics.getImage( Fixture.IMAGE1 ) } );
674
    lca.renderChanges( shell );
650
    lca.renderChanges( shell );
Lines 679-686 Link Here
679
  }
655
  }
680
656
681
  public void testRenderVisibilityIntiallyFalse() throws IOException {
657
  public void testRenderVisibilityIntiallyFalse() throws IOException {
682
    ShellLCA lca = new ShellLCA();
683
684
    lca.renderChanges( shell );
658
    lca.renderChanges( shell );
685
659
686
    Message message = Fixture.getProtocolMessage();
660
    Message message = Fixture.getProtocolMessage();
Lines 689-696 Link Here
689
663
690
  public void testRenderVisibilityInitiallyTrue() throws IOException {
664
  public void testRenderVisibilityInitiallyTrue() throws IOException {
691
    // Client shell is initially visible, SWT shell is not
665
    // Client shell is initially visible, SWT shell is not
692
    ShellLCA lca = new ShellLCA();
693
694
    shell.open();
666
    shell.open();
695
    lca.renderChanges( shell );
667
    lca.renderChanges( shell );
696
668
Lines 698-703 Link Here
698
    assertNull( message.findSetOperation( shell, "visibility" ) );
670
    assertNull( message.findSetOperation( shell, "visibility" ) );
699
  }
671
  }
700
672
673
  public void testRenderOpenExpanded() throws IOException {
674
    lca.render( shell );
675
676
    Message message = Fixture.getProtocolMessage();
677
    CreateOperation operation = message.findCreateOperation( shell );
678
    assertTrue( operation.getPropertyNames().indexOf( "opened" ) == -1 );
679
  }
680
681
  public void testRenderOpen() throws IOException {
682
    shell.open();
683
    lca.renderChanges( shell );
684
685
    Message message = Fixture.getProtocolMessage();
686
    assertEquals( Boolean.TRUE, message.findSetProperty( shell, "opened" ) );
687
  }
688
689
  public void testRenderOpenUnchanged() throws IOException {
690
    Fixture.markInitialized( display );
691
    Fixture.markInitialized( shell );
692
693
    shell.open();
694
    Fixture.preserveWidgets();
695
    lca.renderChanges( shell );
696
697
    Message message = Fixture.getProtocolMessage();
698
    assertNull( message.findSetOperation( shell, "opened" ) );
699
  }
700
701
  private static Control getActiveControl( Shell shell ) {
701
  private static Control getActiveControl( Shell shell ) {
702
    Object adapter = shell.getAdapter( IShellAdapter.class );
702
    Object adapter = shell.getAdapter( IShellAdapter.class );
703
    IShellAdapter shellAdapter = ( IShellAdapter )adapter;
703
    IShellAdapter shellAdapter = ( IShellAdapter )adapter;

Return to bug 370139