Bug 506583

Summary: Provide API to make a jface.Dialog non-modal and using a top-level shell
Product: [Eclipse Project] Platform Reporter: Lars Vogel <Lars.Vogel>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: akurtakov, daniel_megert, Lars.Vogel, psuzzi, sxenos
Version: 4.5Keywords: api
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on:    
Bug Blocks: 506677    

Description Lars Vogel CLA 2016-10-26 16:13:17 EDT
To make a dialog non-modal we currently have to override setShellStyle.

@Override
	protected void setShellStyle(int newShellStyle) {
		super.setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE);
		setBlockOnOpen(false);
	}

Unfortunately this will make the dialog still sit on top of the application window.

AFAIK we currently have no way to make a dialog a top-level shell, e.g., so that I switch between the dialog and the application window with Ctrl+tab.
Comment 1 Lars Vogel CLA 2016-10-26 16:14:27 EDT
Stefan / Alex / Dani, any suggestion how to archive this via new or existing API?
Comment 2 Stefan Xenos CLA 2016-10-27 17:28:31 EDT
> AFAIK we currently have no way to make a dialog a top-level shell, e.g.,
> so that I switch between the dialog and the application window with Ctrl+tab.

If you give it a null parent and make it non-modal, it should end up as a top-level shell.

We reparent modal dialogs to prevent deadlocks.
Comment 3 Dirk Fauth CLA 2016-10-28 02:43:51 EDT
(In reply to Stefan Xenos from comment #2)
> > AFAIK we currently have no way to make a dialog a top-level shell, e.g.,
> > so that I switch between the dialog and the application window with Ctrl+tab.
> 
> If you give it a null parent and make it non-modal, it should end up as a
> top-level shell.
> 
> We reparent modal dialogs to prevent deadlocks.

But as Lars said, you need to override setShellStyle() for this. Checking the sources of org.eclipse.jface.dialogs.Dialog you will notice that SWT.APPLICATION_MODAL is set always.
Comment 4 Stefan Xenos CLA 2017-04-20 13:58:53 EDT
But AFAIK you don't need to override setShellStyle. Most existing dialogs that wish to change the style bits do something like this in their constructor:

setShellStyle(getShellStyle() | SWT.RESIZE);

So if you want to make a nonmodal top-level dialog, you could do this:

public MyDialog() {
   super((Shell) null);

   setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE);
}

Is there something I'm missing? Is there a reason why this either doesn't work, is undesirable, or is too verbose?