Search in sources :

Example 1 with Resource

use of org.eclipse.swt.graphics.Resource in project eclipse.platform.swt by eclipse.

the class GradientDialog method open.

/**
 * Sets up the dialog and opens it.
 */
public int open() {
    final Shell dialog = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.RESIZE | getStyle());
    // $NON-NLS-1$
    dialog.setText(GraphicsExample.getResourceString("Gradient"));
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.marginHeight = 10;
    gridLayout.marginWidth = 10;
    dialog.setLayout(gridLayout);
    // create the controls in the dialog
    createDialogControls(dialog);
    dialog.addListener(SWT.Close, event -> {
        for (int i = 0; i < resources.size(); i++) {
            Object obj = resources.get(i);
            if (obj != null && obj instanceof Resource) {
                ((Resource) obj).dispose();
            }
        }
        dialog.dispose();
    });
    dialog.setDefaultButton(okButton);
    dialog.pack();
    Rectangle rect = getParent().getMonitor().getBounds();
    Rectangle bounds = dialog.getBounds();
    dialog.setLocation(rect.x + (rect.width - bounds.width) / 2, rect.y + (rect.height - bounds.height) / 2);
    dialog.setMinimumSize(bounds.width, bounds.height);
    dialog.open();
    Display display = getParent().getDisplay();
    while (!dialog.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    if (menu1 != null) {
        menu1.dispose();
        menu1 = null;
    }
    if (menu2 != null) {
        menu2.dispose();
        menu2 = null;
    }
    return returnVal;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Resource(org.eclipse.swt.graphics.Resource) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Display(org.eclipse.swt.widgets.Display)

Aggregations

Point (org.eclipse.swt.graphics.Point)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Resource (org.eclipse.swt.graphics.Resource)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1