Search in sources :

Example 11 with ProgressMonitorPart

use of org.eclipse.jface.wizard.ProgressMonitorPart in project dbeaver by dbeaver.

the class MultiPageWizardDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    wizard.addPages();
    wizardSash = new SashForm(composite, SWT.HORIZONTAL);
    wizardSash.setLayoutData(new GridData(GridData.FILL_BOTH));
    pagesTree = new Tree(wizardSash, SWT.SINGLE);
    pagesTree.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite pageContainer = UIUtils.createPlaceholder(wizardSash, 2);
    // Vertical separator
    new Label(pageContainer, SWT.SEPARATOR | SWT.VERTICAL).setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
    pageArea = UIUtils.createPlaceholder(pageContainer, 1);
    GridData gd = new GridData(GridData.FILL_BOTH);
    pageArea.setLayoutData(gd);
    pageArea.setLayout(new GridLayout(1, true));
    wizardSash.setWeights(new int[] { 300, 700 });
    Point maxSize = new Point(0, 0);
    IWizardPage[] pages = wizard.getPages();
    for (IWizardPage page : pages) {
        addPage(null, page, maxSize);
    }
    pagesTree.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            changePage();
        }
    });
    // Select first page
    pagesTree.select(pagesTree.getItem(0));
    changePage();
    // Set title and image from first page
    IDialogPage firstPage = (IDialogPage) pagesTree.getItem(0).getData();
    setTitle(firstPage.getTitle());
    setTitleImage(firstPage.getImage());
    setMessage(firstPage.getDescription());
    // Horizontal separator
    new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Progress monitor
    monitorPart = new ProgressMonitorPart(composite, null, true) {

        @Override
        public void setCanceled(boolean b) {
            super.setCanceled(b);
            if (b) {
                cancelCurrentOperation();
            }
        }
    };
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalIndent = 20;
    gd.verticalIndent = 0;
    monitorPart.setLayoutData(gd);
    monitorPart.setVisible(false);
    return composite;
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Point(org.eclipse.swt.graphics.Point) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IDialogPage(org.eclipse.jface.dialogs.IDialogPage) ProgressMonitorPart(org.eclipse.jface.wizard.ProgressMonitorPart) IWizardPage(org.eclipse.jface.wizard.IWizardPage)

Aggregations

ProgressMonitorPart (org.eclipse.jface.wizard.ProgressMonitorPart)11 GridData (org.eclipse.swt.layout.GridData)8 Composite (org.eclipse.swt.widgets.Composite)6 GridLayout (org.eclipse.swt.layout.GridLayout)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Control (org.eclipse.swt.widgets.Control)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 IStatus (org.eclipse.core.runtime.IStatus)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Status (org.eclipse.core.runtime.Status)2 IDialogPage (org.eclipse.jface.dialogs.IDialogPage)2 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2