Example usage for org.eclipse.jface.dialogs TrayDialog getShell

List of usage examples for org.eclipse.jface.dialogs TrayDialog getShell

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs TrayDialog getShell.

Prototype

@Override
public Shell getShell() 

Source Link

Document

Returns this window's shell.

Usage

From source file:org.eclipse.oomph.ui.OomphDialog.java

License:Open Source License

public static boolean showFirstTimeHelp(final TrayDialog dialog) {
    try {//from w w  w .  j  a  v a2 s . c  o m
        if (dialog.isHelpAvailable()) {
            String key = dialog.getClass().getName();
            String value = new Date().toString();

            if (HISTORY.compareAndSetProperty(key, value)) {
                UIUtil.asyncExec(dialog.getShell(), new Runnable() {
                    public void run() {
                        try {
                            Method method = ReflectUtil.getMethod(TrayDialog.class, "helpPressed");
                            ReflectUtil.invokeMethod(method, dialog);
                        } catch (Throwable ex) {
                            UIPlugin.INSTANCE.log(ex);
                        }
                    }
                });

                return true;
            }
        }
    } catch (Throwable ex) {
        UIPlugin.INSTANCE.log(ex);
    }

    return false;
}

From source file:org.eclipse.oomph.ui.OomphDialog.java

License:Open Source License

public static void hookTray(final TrayDialog dialog)
        throws IllegalStateException, UnsupportedOperationException {
    final Control trayControl = getFieldValue(dialog, "trayControl");
    final Label rightSeparator = getFieldValue(dialog, "rightSeparator");
    final Sash sash = getFieldValue(dialog, "sash");
    if (trayControl == null || rightSeparator == null || sash == null) {
        return;//from w w w  .  java 2s . co m
    }

    final GridData data = (GridData) trayControl.getLayoutData();
    sash.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            if (event.detail == SWT.DRAG) {
                Shell shell = dialog.getShell();
                Rectangle clientArea = shell.getClientArea();
                int newWidth = clientArea.width - event.x - (sash.getSize().x + rightSeparator.getSize().x);
                if (newWidth != data.widthHint) {
                    data.widthHint = newWidth;
                    shell.layout();
                }
            }
        }
    });
}