Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340736 - RWT Dialog setDefaultButton is not recognized properly
Summary: RWT Dialog setDefaultButton is not recognized properly
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5 M2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-23 06:12 EDT by Thomas Jodes CLA
Modified: 2011-09-19 07:27 EDT (History)
1 user (show)

See Also:


Attachments
RCP and RAP projects for reproducibility (34.08 KB, application/zip)
2011-03-23 06:13 EDT, Thomas Jodes CLA
no flags Details
Proposed fix (4.11 KB, patch)
2011-04-04 11:17 EDT, Ivan Furnadjiev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Jodes CLA 2011-03-23 06:12:09 EDT
Build Identifier: 

Default button reset not possible nor applicable
Short discussion see:
http://www.eclipse.org/forums/index.php?t=msg&th=206446&start=0&S=470c936971ffebeff518b1fb63a097bc

Reproducible: Always

Steps to Reproduce:
1. Extract attached zip and import application snippet projects for RCP and RAP
2. Run the snippet applications for RCP and RAP
3. Play around the option buttons setting default button.
- You 'll see that in RAP the default button cannot be set to empty
Comment 1 Thomas Jodes CLA 2011-03-23 06:13:01 EDT
Created attachment 191738 [details]
RCP and RAP projects for reproducibility

RCP and RAP projects for reproducibility
Comment 2 Thomas Jodes CLA 2011-03-23 06:14:02 EDT
I do not know if or how this issue is still related with the assumed-to-be fixed swt bug report https://bugs.eclipse.org/bugs/show_bug.cgi?id=297477
Comment 3 Ivan Furnadjiev CLA 2011-04-04 05:25:51 EDT
Thomas, just updated the method Shell#setDefaultButton to match the SWT Decorations#setDefaultButton. This change integrates the fix for bug 297477 in RAP. The main difference between RAP and RCP is that in RCP when a button receives a focus it is set as temporary default button (without saving). When a button looses a focus, setDefaultButton( null, false) is called. But in both RAP/RCP the test case bellow works - need to call setDefaultButton(null) twice to remove the default button:
public void testResetDefaultButton() {
    Display display = new Display();
    Shell shell = new Shell( display, SWT.NONE );
    Button defaultButton = new Button( shell, SWT.PUSH );
    shell.setDefaultButton( defaultButton );
    shell.setDefaultButton( null );
    assertSame( defaultButton, shell.getDefaultButton() );
    shell.setDefaultButton( null );
    assertNull( shell.getDefaultButton() );
 }
Comment 4 Ivan Furnadjiev CLA 2011-04-04 10:30:33 EDT
Test case that pass in SWT but not in RAP:
public void testSetDefaultButtonOnFocus() {
    Display display = new Display();
    Shell shell = new Shell( display, SWT.NONE );
    shell.open();
    assertNull( shell.getDefaultButton() );
    Button button = new Button( shell, SWT.PUSH );
    Combo combo = new Combo( shell, SWT.NONE );
    button.setFocus();
    assertSame( button, shell.getDefaultButton() );
    combo.setFocus();
    assertNull( shell.getDefaultButton() );
    display.dispose();
  }
Comment 5 Ivan Furnadjiev CLA 2011-04-04 11:17:04 EDT
Created attachment 192469 [details]
Proposed fix

With this patch I can't see more differences for defaultButton behavior in RAP and RCP. JUnit tests included, passed in RAP and RCP. Thomas, could you confirm this?
Comment 6 Thomas Jodes CLA 2011-05-24 04:28:08 EDT
Hi Ivan,

sorry for the late reply - however, I can confirm this, just tested against RAP 1.4RC1.
Comment 7 Thomas Jodes CLA 2011-05-24 10:09:53 EDT
Well, when will the changes be included? As RAP stands at RC1 now...
Comment 8 Ivan Furnadjiev CLA 2011-05-24 10:24:25 EDT
Thomas, as we are at RC3 now (built RC2 today), it's too late to include this fix in 1.4 release. Probably will be included in 1.5M1.
Comment 9 Ivan Furnadjiev CLA 2011-09-19 07:27:04 EDT
Applied patch to CVS HEAD with some refactorings.