Example usage for org.eclipse.jface.dialogs IDialogPage getControl

List of usage examples for org.eclipse.jface.dialogs IDialogPage getControl

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogPage getControl.

Prototype

Control getControl();

Source Link

Document

Returns the top level control for this dialog page.

Usage

From source file:org.eclipse.oomph.internal.ui.Capture.java

License:Open Source License

protected Image capture(IDialogPage page, Map<Control, Image> decorations) {
    Control control = page.getControl();

    // Get the control of the overall page.
    Composite pageControl = control.getParent().getParent().getParent();
    Control[] children = pageControl.getChildren();

    // Get the overall wizard control.
    Composite wizardControl = pageControl.getParent();

    // Compute the bounds to capture by extending the bounds of the page control to include the title area but to exclude the bottom button area.
    Rectangle bounds = pageControl.getBounds();
    Point size = children[1].getSize();
    bounds.height += bounds.y - 2;/* w ww .  j av  a2 s .co  m*/
    bounds.y = 0;
    bounds.height -= size.y;

    Point displayOffset = wizardControl.toDisplay(bounds.x, bounds.y);
    Image result = AccessUtil.capture(control.getDisplay(),
            new Rectangle(displayOffset.x, displayOffset.y, bounds.width, bounds.height));
    if (decorations != null && !decorations.isEmpty()) {
        decorate(result, wizardControl, bounds, decorations);
    }

    return result;
}

From source file:org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPageSettings.java

License:Open Source License

private void createProviderPage(Composite parent) {
    if (this.connectionEditor != null) {
        return;//  w  w w .  j  a v a2 s  .c  o m
    }
    if (getControl() != null) {
        getControl().dispose();
    }

    try {
        this.connectionEditor = viewDescriptor.createView(IDataSourceConnectionEditor.class);
        this.connectionEditor.setSite(this);
        // init sub pages (if any)
        getSubPages();

        if (wizard.isNew() && !ArrayUtils.isEmpty(subPages)) {
            // Create tab folder
            List<IDialogPage> allPages = new ArrayList<>();
            allPages.add(connectionEditor);
            Collections.addAll(allPages, subPages);

            TabFolder tabFolder = new TabFolder(parent, SWT.TOP);
            tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));

            for (IDialogPage page : allPages) {
                TabItem item = new TabItem(tabFolder, SWT.NONE);
                page.createControl(tabFolder);
                Control pageControl = page.getControl();
                item.setControl(pageControl);
                item.setText(CommonUtils.isEmpty(page.getTitle()) ? "General" : page.getTitle());
                item.setToolTipText(page.getDescription());
            }
            tabFolder.setSelection(0);
            setControl(tabFolder);
        } else {
            // Create single editor control
            this.connectionEditor.createControl(parent);
            setControl(this.connectionEditor.getControl());
        }

        UIUtils.setHelp(getControl(), IHelpContextIds.CTX_CON_WIZARD_SETTINGS);
    } catch (Exception ex) {
        log.warn(ex);
        setErrorMessage("Can't create settings dialog: " + ex.getMessage());
    }
    parent.layout();
}

From source file:org.jkiss.dbeaver.ui.dialogs.MultiPageWizardDialog.java

License:Open Source License

private TreeItem addPage(TreeItem parentItem, IDialogPage page, Point maxSize) {
    boolean hasPages = pagesTree.getItemCount() != 0;
    page.createControl(pageArea);/*w w  w  .  jav a  2 s .co m*/
    Control control = page.getControl();
    Point pageSize = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    if (pageSize.x > maxSize.x)
        maxSize.x = pageSize.x;
    if (pageSize.y > maxSize.y)
        maxSize.y = pageSize.y;
    GridData gd = (GridData) control.getLayoutData();
    if (gd == null) {
        gd = new GridData(GridData.FILL_BOTH);
        control.setLayoutData(gd);
    }
    gd.exclude = hasPages;
    control.setVisible(!gd.exclude);

    TreeItem item = parentItem == null ? new TreeItem(pagesTree, SWT.NONE) : new TreeItem(parentItem, SWT.NONE);
    item.setText(page.getTitle());
    item.setData(page);

    // Ad sub pages
    if (page instanceof ICompositeDialogPage) {
        IDialogPage[] subPages = ((ICompositeDialogPage) page).getSubPages();
        if (!ArrayUtils.isEmpty(subPages)) {
            for (IDialogPage subPage : subPages) {
                addPage(item, subPage, maxSize);
            }
            item.setExpanded(true);
        }
    }

    return item;
}

From source file:org.jkiss.dbeaver.ui.dialogs.MultiPageWizardDialog.java

License:Open Source License

private void changePage() {
    pageArea.setRedraw(false);/*from  w w  w  . j  a v a  2  s  .com*/
    try {
        TreeItem[] selection = pagesTree.getSelection();
        if (selection.length != 1) {
            return;
        }
        TreeItem newItem = selection[0];
        if (prevPage == newItem.getData()) {
            return;
        }

        GridData gd;
        if (prevPage != null) {
            gd = (GridData) prevPage.getControl().getLayoutData();
            gd.exclude = true;
            prevPage.setVisible(false);
        }

        IDialogPage page = (IDialogPage) newItem.getData();
        gd = (GridData) page.getControl().getLayoutData();
        gd.exclude = false;
        page.setVisible(true);
        setTitle(page.getTitle());
        setMessage(page.getDescription());

        prevPage = page;
        pageArea.layout();
    } finally {
        pageArea.setRedraw(true);
    }
}