Bug 489373 - Dialog buttons don't work all the time
Summary: Dialog buttons don't work all the time
Status: ASSIGNED
Alias: None
Product: RAP
Classification: RT
Component: JFace (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 10
: P3 normal with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-10 12:03 EST by Wim Anckaert CLA
Modified: 2016-03-14 08:47 EDT (History)
4 users (show)

See Also:


Attachments
EntryPoint for reproducing error. (3.64 KB, text/plain)
2016-03-10 12:03 EST, Wim Anckaert CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wim Anckaert CLA 2016-03-10 12:03:13 EST
Created attachment 260224 [details]
EntryPoint for reproducing error.

Dears,

in some cases the default OK, Cancel button of a custom JFace dialog or MessageDialog (not 100% sure it's only JFace dialog related) don't react, leaving the dialog open. The dialog can only be closed by using the X button in the title bar.
This only happens once per session. And not all the time.

In attachment is the code to reproduce it.
The steps to reproduce are : 

- surfing to entrypoint
- clicking button => dialog opens
- pressing ok : this works.
- altering code (fe btn.setText("Pushing second load") );
- refreshing browser
- clicking button => dialog opens
- pressing ok : dialog stays open.

While debugging I found the following difference between working and not working in EventUtil.isShellAccessible
Working : parameter shell == shell.getDisplay.getActiveShell()
not working : parameter shell != shell.getDisplay.getActiveShell()

Kind Regards
Comment 1 Wim Anckaert CLA 2016-03-14 05:18:18 EDT
Changing the style bit of shell to SWT.PRIMARY_MODAL seems to resolve this

final Shell shell = new Shell(display, SWT.PRIMARY_MODAL);
Comment 2 Ivan Furnadjiev CLA 2016-03-14 05:48:05 EDT
I'm looking into the issue right now... will let you know about the results.
Comment 3 Ivan Furnadjiev CLA 2016-03-14 06:25:18 EDT
The problem in your code is the Shell resize event listener. In this listener you set the maximized state to the shell again and again which indirectly set the active shell back to dialog parent shell. Thus, dialog shell is no longer active and buttons can't be clicked. In RAP, because of text-size-determination, all shells are temporary resized (enlarge than reduced to original size) when some text chages. It's not a good idea to set the maximized state in these temporary resize events.
Comment 4 Ivan Furnadjiev CLA 2016-03-14 06:37:41 EDT
.... why do you set the maximized state in display/shell resize listener?
Comment 5 Wim Anckaert CLA 2016-03-14 06:43:18 EDT
When the user resizes the browser, we want to relayout the shell and utilize the full available screen.
If I remove setMaximized(true) from the shell resize listener, but leave it in the display resize listener then it still resizes nicely and the dialog buttons react fine.
Comment 6 Ivan Furnadjiev CLA 2016-03-14 06:49:45 EDT
When you resize the browser the maximized shell will stay maximized (utilize the full available screen) without a need to set the maximized state again in resize listener. The workaround for the issue is simply to remove the setMaximized method call in both (display and shell) resize listeners.
Comment 7 Wim Anckaert CLA 2016-03-14 06:55:43 EDT
When I remove both setMaximized statements the shell doesn't resize when the browser is enlarged.
Tested in Chrome (48.0.2564.116 m), FF (44.0.2), Edge, IE (11).
Instead of the white background I see a gray background of the part that is expanded.
When the setMaximized stays in the display resize event then the shell will expand and wil use the entire space in the browser.
Comment 8 Ivan Furnadjiev CLA 2016-03-14 07:16:39 EDT
(In reply to comment #7)
> When I remove both setMaximized statements the shell doesn't resize when the
> browser is enlarged.
Don't set the location to (0,0) or set it before the miximized state. Setting the location (bounds) will reset shell maximized state.
Comment 9 Ivan Furnadjiev CLA 2016-03-14 07:23:47 EDT
Your code shoud work fine without setting the shell location and maximized state in display/shell resize listeners.
Comment 10 Wim Anckaert CLA 2016-03-14 07:42:43 EDT
Indeed, when changing the code in following way:
- shell.setLocation(0, 0) before shell.setMaximized
- remove shell.setMaximized from resize listeners of display and shell
the dialog buttons still react and the shell resizes to the size of the browser.

tx!
Comment 11 Ivan Furnadjiev CLA 2016-03-14 08:20:15 EDT
For completeness you don't need to set the location, it's (0,0) by default. I think both resize listeners are also not needed, the layout will be performed.
Comment 12 Wim Anckaert CLA 2016-03-14 08:47:55 EDT
Indeed, I removed the set location + the resizelisteners and the layout is performed.