Bug 506583 - Provide API to make a jface.Dialog non-modal and using a top-level shell
Summary: Provide API to make a jface.Dialog non-modal and using a top-level shell
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks: 506677
  Show dependency tree
 
Reported: 2016-10-26 16:13 EDT by Lars Vogel CLA
Modified: 2017-04-20 13:58 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?