1.) Purpose
Widget for quick viewing of OSX files. Basically, on a Mac, when you select a file and press the spacebar, you get a quick look at that file. I am trying to reproduce this functionality using SWT + JFace (mmmaybe JavaFX).
It will be Shellfor me.

2.) Specificity
The preview widget will be APPLICATION_MODAL Shellattached to StructuredViewer.
I do not want to recreate Shellevery time I open a preview. I just want it hidden. This preview is supposed to be quick .
I want to close this Shellon ESCand SPACE.
(PDF, JPEG, PNG, TXT ..), . Shell , .
, . , , - .
3.)
Shell , "" KeyEvent s. , Shell , .
Display. / , / Shell. , , RCP, ( - ).
4.) SSCCE
, , Text , Shell , .
public class SSCCE_ShellWithShellParent
{
private static final int CHILD_SHELL_STYLE = SWT.BORDER | SWT.RESIZE | SWT.TITLE | SWT.CLOSE | SWT.APPLICATION_MODAL;
public static void main(final String[] args)
{
new SSCCE_ShellWithShellParent();
}
private SSCCE_ShellWithShellParent()
{
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final Shell childShell = new Shell(shell, CHILD_SHELL_STYLE);
childShell.setLayout(new FillLayout());
childShell.pack();
createChildContents(childShell);
final KeyAdapter keyListener = new KeyAdapter()
{
@Override public void keyPressed(final KeyEvent e)
{
final Object source = e.getSource();
if (source == shell)
System.out.println(e.keyCode);
else
System.err.println(e.keyCode);
if (e.keyCode == 27)
shell.close();
if (e.keyCode == 32 && e.getSource() == shell)
childShell.open();
}
};
childShell.addKeyListener(keyListener);
shell.addKeyListener(keyListener);
shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
private void createChildContents(final Shell childShell)
{
new Text(childShell, SWT.NULL);
}
}
5.) TL; DR
KeyListener Shell .