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

Bug 393522

Summary: [Shell] Parent shell of a primary modal dialog is accessible
Product: [RT] RAP Reporter: Karl Hönninger <karl>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ivan
Version: 2.0   
Target Milestone: 2.0 M3   
Hardware: All   
OS: All   
Whiteboard:

Description Karl Hönninger CLA 2012-11-05 04:38:54 EST
The parent shell of a primary modal dialog is accessible. I would expect that the parent is inaccessible (which is the case for an application modal dialog).

I found this behaviour in version '2.0.0.20121001-1623' and in mode 'OperationMode.SWT_COMPATIBILITY'. 

Here is a short snippet to reproduce this:



package org.openxma.rwt.launch;

import org.eclipse.rap.rwt.lifecycle.IEntryPoint;

public class RWTTest implements IEntryPoint {

	public int createUI() {
		
		Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setText("Parent");
		shell.setSize(500,400);		
		shell.setLayout(new FillLayout(SWT.VERTICAL));

		/* primary modal shell */
		Button primaryModalButton = new Button(shell, SWT.PUSH);
		primaryModalButton.setText("Open primary modal shell");		
		primaryModalButton.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent arg0) {
				Shell primaryModalShell = new Shell(shell, SWT.PRIMARY_MODAL | SWT.TITLE | SWT.CLOSE);
				primaryModalShell.setText("Primary modal");
				primaryModalShell.open();
				eventLoop(primaryModalShell);
			}
		});
		/* application modal shell */
		Button applicationModalButton = new Button(shell, SWT.PUSH);
		applicationModalButton.setText("Open application modal shell");
		applicationModalButton.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent arg0) {
				Shell applicationModalShell = new Shell(shell, SWT.APPLICATION_MODAL | SWT.TITLE | SWT.CLOSE);
				applicationModalShell.setText("Application modal");
				applicationModalShell.open();
				eventLoop(applicationModalShell);
			}
		});

        /* open parent shell */
		shell.open();
		eventLoop(shell);
		return 0;
	}

	protected void eventLoop(Shell shell) {
		Display display = shell.getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}
}
Comment 1 Ivan Furnadjiev CLA 2012-11-05 07:49:53 EST
Currently only APPLICATION_MODAL Shell is fully supported. The SWT.PRIMARY_MODAL style flag has been introduced by bug 231864, but never really implemented due to old client-side Shell restrictions. More over the style flag is marked as HINT, which means it's normal not to be supported on some platforms.
Comment 2 Karl Hönninger CLA 2012-11-05 15:55:55 EST
Regarding not supported modality styles you can find a note here: 

http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Dialog.html

Here is an extract: 
"Note: The modality styles supported by this class are treated as HINTs, because not all are supported by every subclass on every platform. If a modality style is not supported, it is "upgraded" to a more restrictive modality style that is supported. For example, if PRIMARY_MODAL is not supported by a particular dialog, it would be upgraded to APPLICATION_MODAL. In addition, as is the case for shells, the window manager for the desktop on which the instance is visible has ultimate control over the appearance and behavior of the instance, including its modality."

Maybe as a possible solution such an upgrade could be taken in consideration for RWT.
Comment 3 Ivan Furnadjiev CLA 2012-11-05 16:07:22 EST
(In reply to comment #2)
> Maybe as a possible solution such an upgrade could be taken in consideration
> for RWT.
Yes... We will implement the PRIMARY_MODAL style flag as APPLICATION_MODAL.
Comment 4 Ivan Furnadjiev CLA 2012-11-05 16:29:34 EST
Fixed as suggested with commit 7399bb4dd7f0d17dc2234467fa5e178b936fad27.